Fastcgipp::Transceiver Class Reference

Handles low level communication with "the other side". More...

#include <transceiver.hpp>

List of all members.

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, fdBufferfdBuffers
 Container associating file descriptors with their receive buffers.


Detailed Description

Handles low level communication with "the other side".

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.


Constructor & Destructor Documentation

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.

Parameters:
[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.


Member Function Documentation

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.

Returns:
Boolean value indicating whether there is data to be transmitted or received

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]

void Fastcgipp::Transceiver::secureWrite ( size_t  size,
Protocol::FullId  id,
bool  kill 
) [inline]

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]

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().


Member Data Documentation

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().

Function to call to pass messages to requests.

Definition at line 258 of file transceiver.hpp.

Referenced by handler().

Socket to listen for connections on.

Definition at line 263 of file transceiver.hpp.

Referenced by handler(), and Transceiver().

Input file descriptor to the wakeup socket pair.

Definition at line 265 of file transceiver.hpp.

Referenced by handler(), and Transceiver().

Output file descriptor to the wakeup socket pair.

Definition at line 267 of file transceiver.hpp.

Referenced by Transceiver(), and wake().


The documentation for this class was generated from the following files:

Generated on Thu Dec 11 01:47:28 2008 for fastcgi++ by  doxygen 1.5.7.1