#include <transceiver.hpp>
Classes | |
class | Buffer |
Buffer type for transmission of FastCGI records More... | |
struct | fdBuffer |
Buffer type for receiving FastCGI records More... | |
Public Member Functions | |
bool | handler () |
General transceiver handler. | |
Block | requestWrite (size_t size) |
Direct interface to Buffer::requestWrite(). | |
void | secureWrite (size_t size, Protocol::FullId id, bool kill) |
Direct interface to Buffer::secureWrite(). | |
Transceiver (int fd_, boost::function< void(Protocol::FullId, Message)> sendMessage_) | |
Constructor. | |
void | sleep () |
Blocks until there is data to receive or a call to wake() is made. | |
void | wake () |
Forces a wakeup from a call to sleep(). | |
Private Member Functions | |
int | transmit () |
Transmit all buffered data possible. | |
Private Attributes | |
Buffer | buffer |
Buffer for transmitting data | |
boost::function< void(Protocol::FullId, Message)> | sendMessage |
Function to call to pass messages to requests. | |
std::vector< pollfd > | pollFds |
poll() file descriptors container | |
int | socket |
Socket to listen for connections on. | |
int | wakeUpFdIn |
Input file descriptor to the wakeup socket pair. | |
int | wakeUpFdOut |
Output file descriptor to the wakeup socket pair. | |
std::map< int, fdBuffer > | fdBuffers |
Container associating file descriptors with their receive buffers. |
This class handles the sending/receiving/buffering of data through the OS level sockets and also the creation/destruction of the sockets themselves.
Definition at line 79 of file transceiver.hpp.
Fastcgipp::Transceiver::Transceiver | ( | int | fd_, | |
boost::function< void(Protocol::FullId, Message)> | sendMessage_ | |||
) |
Constructor.
Construct a transceiver object based on an initial file descriptor to listen on and a function to pass messages on to.
[in] | fd_ | File descriptor to listen for connections on |
[in] | sendMessage_ | Function to call to pass messages to requests |
Definition at line 192 of file transceiver.cpp.
References pollFds, socket, wakeUpFdIn, and wakeUpFdOut.
bool Fastcgipp::Transceiver::handler | ( | ) |
General transceiver handler.
This function is called by Manager::handler() to both transmit data passed to it from requests and relay received data back to them as a Message. The function will return true if there is nothing at all for it to do.
Definition at line 65 of file transceiver.cpp.
References Fastcgipp::Message::data, fdBuffers, pollFds, Fastcgipp::reventsZero(), sendMessage, Fastcgipp::Message::size, socket, transmit(), Fastcgipp::Message::type, and wakeUpFdIn.
Referenced by Fastcgipp::Manager< T >::handler().
Block Fastcgipp::Transceiver::requestWrite | ( | size_t | size | ) | [inline] |
Direct interface to Buffer::requestWrite().
Definition at line 93 of file transceiver.hpp.
References buffer, and Fastcgipp::Transceiver::Buffer::requestWrite().
Referenced by Fastcgipp::Request< charT >::complete(), Fastcgipp::Fcgistream< charT, traits >::Fcgibuf::emptyBuffer(), Fastcgipp::Request< charT >::handler(), and Fastcgipp::Manager< T >::localHandler().
void Fastcgipp::Transceiver::secureWrite | ( | size_t | size, | |
Protocol::FullId | id, | |||
bool | kill | |||
) | [inline] |
Direct interface to Buffer::secureWrite().
Definition at line 95 of file transceiver.hpp.
References buffer, Fastcgipp::Transceiver::Buffer::secureWrite(), and transmit().
Referenced by Fastcgipp::Request< charT >::complete(), Fastcgipp::Fcgistream< charT, traits >::Fcgibuf::emptyBuffer(), Fastcgipp::Request< charT >::handler(), and Fastcgipp::Manager< T >::localHandler().
void Fastcgipp::Transceiver::sleep | ( | ) | [inline] |
Blocks until there is data to receive or a call to wake() is made.
Definition at line 106 of file transceiver.hpp.
References pollFds.
Referenced by Fastcgipp::Manager< T >::handler().
int Fastcgipp::Transceiver::transmit | ( | ) | [private] |
Transmit all buffered data possible.
Definition at line 24 of file transceiver.cpp.
References buffer, Fastcgipp::Transceiver::Buffer::empty(), fdBuffers, Fastcgipp::Transceiver::Buffer::freeRead(), pollFds, and Fastcgipp::Transceiver::Buffer::requestRead().
Referenced by handler(), and secureWrite().
void Fastcgipp::Transceiver::wake | ( | ) |
Forces a wakeup from a call to sleep().
Definition at line 186 of file transceiver.cpp.
References wakeUpFdOut.
Referenced by Fastcgipp::Manager< T >::push().
Buffer Fastcgipp::Transceiver::buffer [private] |
Buffer for transmitting data
Definition at line 256 of file transceiver.hpp.
Referenced by requestWrite(), secureWrite(), and transmit().
std::map<int, fdBuffer> Fastcgipp::Transceiver::fdBuffers [private] |
Container associating file descriptors with their receive buffers.
Definition at line 270 of file transceiver.hpp.
Referenced by handler(), and transmit().
std::vector<pollfd> Fastcgipp::Transceiver::pollFds [private] |
poll() file descriptors container
Definition at line 261 of file transceiver.hpp.
Referenced by handler(), sleep(), Transceiver(), and transmit().
boost::function<void(Protocol::FullId, Message)> Fastcgipp::Transceiver::sendMessage [private] |
Function to call to pass messages to requests.
Definition at line 258 of file transceiver.hpp.
Referenced by handler().
int Fastcgipp::Transceiver::socket [private] |
Socket to listen for connections on.
Definition at line 263 of file transceiver.hpp.
Referenced by handler(), and Transceiver().
int Fastcgipp::Transceiver::wakeUpFdIn [private] |
Input file descriptor to the wakeup socket pair.
Definition at line 265 of file transceiver.hpp.
Referenced by handler(), and Transceiver().
int Fastcgipp::Transceiver::wakeUpFdOut [private] |
Output file descriptor to the wakeup socket pair.
Definition at line 267 of file transceiver.hpp.
Referenced by Transceiver(), and wake().