fastcgi++
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
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()
void freeFd (int fd_)
 Helper function for freeFd(int fd, std::vector<pollfd> pollFds, std::map<int, fdBuffer> fdBuffers)

Static Public Member Functions

static void freeFd (int fd, std::vector< pollfd > &pollFds, std::map< int, fdBuffer > &fdBuffers)
 Free fd/pipe and all it's associated resources.

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 195 of file transceiver.cpp.

References pollFds, socket, wakeUpFdIn, and wakeUpFdOut.


Member Function Documentation

void Fastcgipp::Transceiver::freeFd ( int  fd,
std::vector< pollfd > &  pollFds,
std::map< int, fdBuffer > &  fdBuffers 
) [static]

Free fd/pipe and all it's associated resources.

By calling this function you close the passed file descriptor and free up it's associated buffers and resources. It is safe to call this function at any time with any fd(even bad ones). If requests still exists with this fd then they will be lost.

Parameters:
fdFile descriptor to delete/free up
pollFdsEpoll container
fdBuffersContainer of fd/pipe buffers

Definition at line 316 of file transceiver.cpp.

Referenced by transmit().

void Fastcgipp::Transceiver::freeFd ( int  fd_) [inline]

Helper function for freeFd(int fd, std::vector<pollfd> pollFds, std::map<int, fdBuffer> fdBuffers)

Definition at line 292 of file transceiver.hpp.

References fdBuffers, freeFd(), and pollFds.

Referenced by freeFd().

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 64 of file transceiver.cpp.

References Fastcgipp::reventsZero(), Fastcgipp::Message::size, and Fastcgipp::Message::type.

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

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

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.

Forces a wakeup from a call to sleep()

Definition at line 189 of file transceiver.cpp.


Member Data Documentation

Buffer for transmitting data

Definition at line 258 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 272 of file transceiver.hpp.

Referenced by freeFd().

std::vector<pollfd> Fastcgipp::Transceiver::pollFds [private]

poll() file descriptors container

Definition at line 263 of file transceiver.hpp.

Referenced by freeFd(), sleep(), and Transceiver().

Function to call to pass messages to requests.

Definition at line 260 of file transceiver.hpp.

Socket to listen for connections on.

Definition at line 265 of file transceiver.hpp.

Referenced by Transceiver().

Input file descriptor to the wakeup socket pair.

Definition at line 267 of file transceiver.hpp.

Referenced by Transceiver().

Output file descriptor to the wakeup socket pair.

Definition at line 269 of file transceiver.hpp.

Referenced by Transceiver().


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