|
|
The socket port is an internal class which is attached to and then serviced by a specific SocketService "object". Derived versions of this class offer specific functionality for specific protocols. Both Common C++ supporting frameworks and application objects may be derived from related protocol specific base classes.
SocketPort (SocketService *svc, TCPSocket &tcp) |
Construct an accepted TCP socket connection from a specific bound TCP server. This is meant to derive advanced application specific TCP servers that can be thread pooled.
Parameters:
svc | pool thread object. |
tcp | socket object to accept. |
SocketPort (SocketService *svc, const InetAddress &ia, tpport_t port) |
Construct a bound UDP socket for use in deriving realtime UDP streaming protocols handled by thread pool objects.
Parameters:
svc | pool thread object. |
ia | address of interface to bind. |
port | number to bind to. |
~SocketPort () |
Disconnect the socket from the service thread pool and the remote connection.
void setDetectPending ( bool ) |
Used to indicate if the service thread should monitor pending data for us.
bool getDetectPending ( void ) |
Get the current state of the DetectPending flag.
void setDetectOutput ( bool ) |
Used to indicate if output ready monitoring should be performed by the service thread.
bool getDetectOutput ( void ) |
Get the current state of the DetectOutput flag.
void Expired (void) |
Called by the service thread pool when the objects timer has expired. Used for timed events.
void Pending (void) |
Called by the service thread pool when input data is pending for this socket.
void Output (void) |
Called by the service thread pool when output data is pending for this socket.
void Disconnect (void) |
Called by the service thread pool when a disconnect has occured.
sockerror_t Connect (const InetAddress &ia, tpport_t port) |
Connect a Socket Port to a known peer host. This is normally used with the UDP constructor. This is also performed as a non-blocking operation under Posix systems to prevent delays in a callback handler.
Parameters:
ia | address of remote host or subnet. |
port | number of remote peer(s). |
Returns: 0 if successful.
inline int Send (void *buf, int len) |
Transmit "send" data to a connected peer host. This is not public by default since an overriding protocol is likely to be used in a derived class.
Parameters:
address | of buffer to send. |
len | of bytes to send. |
Returns: number of bytes sent.
inline int Recv (void *buf, size_t len) |
Receive a message from any host. This is used in derived classes to build protocols.
Parameters:
pointer | to packet buffer to receive. |
len | of packet buffer to receive. |
Returns: number of bytes received.
inline int Peek (void *buf, size_t len) |
Examine the content of the next packet. This can be used to build "smart" line buffering for derived TCP classes.
Parameters:
pointer | to packet buffer to examine. |
len | of packet buffer to examine. |
Returns: number of bytes actually available.
void setTimer (timeout_t timeout = 0) |
Derived setTimer to notify the service thread pool of change in expected timeout. This allows SocketService to reschedule all timers. Otherwise same as TimerPort.
Parameters:
timeout | in milliseconds. |
Reimplemented from TimerPort
void incTimer (timeout_t timeout) |
Derived incTimer to notify the service thread pool of a change in expected timeout. This allows SocketService to reschedule all timers. Otherwise same as TimerPort.
Parameters:
timeout | in milliseconds. |
Reimplemented from TimerPort