The socket port is an internal class which is attached to and then serviced by a specific SocketService "object". base class for realtime and thread pool serviced protocols.
More...
The socket port is an internal class which is attached to and then serviced by a specific SocketService "object". base class for realtime and thread pool serviced protocols.
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.
A special set of classes, "SocketPort" and "SocketService", exist for building realtime streaming media servers on top of UDP and TCP protocols. The "SocketPort" is used to hold a connected or associated TCP or UDP socket which is being "streamed" and which offers callback methods that are invoked from a "SocketService" thread. SocketService's can be pooled into logical thread pools that can service a group of SocketPorts. A millisecond accurate "timer" is associated with each SocketPort and can be used to time synchronize SocketPort I/O operations.
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.
Returns:
0 if successful.
Parameters:
ia
address of remote host or subnet.
port
number of remote peer(s).
void SocketPort::Disconnect (
void ) [inline, protected, virtual]
Called by the service thread pool when a disconnect has occured.
void SocketPort::Expired (
void ) [inline, protected, virtual]
Called by the service thread pool when the objects timer has expired.
Used for timed events.
void SocketPort::Output (
void ) [inline, protected, virtual]
Called by the service thread pool when output data is pending for this socket.
int SocketPort::Peek (
void * buf,
size_t len ) [inline, protected]
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 SocketPort::Pending (
void ) [inline, protected, virtual]
Called by the service thread pool when input data is pending for this socket.
int SocketPort::Recv (
void * buf,
size_t len ) [inline, protected]
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.
int SocketPort::Send (
void * buf,
int len ) [inline, protected]
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.