class SocketPort

base class for realtime and thread pool serviced protocols. More...

Full nameost::SocketPort
Definition#include <socket.h>
Inheritsost::Socket [public ], ost::TimerPort [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Protected Methods


Detailed Description

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.

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.

 SocketPort (SocketService *svc, TCPSocket &tcp)

SocketPort

[protected]

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:
svcpool thread object.
tcpsocket object to accept.

 SocketPort (SocketService *svc, const InetAddress &ia, tpport_t port)

SocketPort

[protected]

Construct a bound UDP socket for use in deriving realtime UDP streaming protocols handled by thread pool objects.

Parameters:
svcpool thread object.
iaaddress of interface to bind.
portnumber to bind to.

void  Attach ( SocketService* svc )

Attach

[protected]

Attach yourself to the service pool thread object. The later version.

Parameters:
svcpool thread object

 ~SocketPort ()

~SocketPort

[protected virtual]

Disconnect the socket from the service thread pool and the remote connection.

void  setDetectPending ( bool )

setDetectPending

[protected]

Used to indicate if the service thread should monitor pending data for us.

bool  getDetectPending ( void )

getDetectPending

[protected const]

Get the current state of the DetectPending flag.

void  setDetectOutput ( bool )

setDetectOutput

[protected]

Used to indicate if output ready monitoring should be performed by the service thread.

bool  getDetectOutput ( void )

getDetectOutput

[protected const]

Get the current state of the DetectOutput flag.

void  Expired (void)

Expired

[protected virtual]

Called by the service thread pool when the objects timer has expired. Used for timed events.

void  Pending (void)

Pending

[protected virtual]

Called by the service thread pool when input data is pending for this socket.

void  Output (void)

Output

[protected virtual]

Called by the service thread pool when output data is pending for this socket.

void  Disconnect (void)

Disconnect

[protected virtual]

Called by the service thread pool when a disconnect has occured.

sockerror_t  Connect (const InetAddress &ia, tpport_t port)

Connect

[protected]

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:
iaaddress of remote host or subnet.
portnumber of remote peer(s).

Returns: 0 if successful.

inline int  Send (const void *buf, int len)

Send

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

Parameters:
addressof buffer to send.
lenof bytes to send.

Returns: number of bytes sent.

inline int  Recv (void *buf, size_t len)

Recv

[protected]

Receive a message from any host. This is used in derived classes to build protocols.

Parameters:
pointerto packet buffer to receive.
lenof packet buffer to receive.

Returns: number of bytes received.

inline int  Peek (void *buf, size_t len)

Peek

[protected]

Examine the content of the next packet. This can be used to build "smart" line buffering for derived TCP classes.

Parameters:
pointerto packet buffer to examine.
lenof packet buffer to examine.

Returns: number of bytes actually available.

void  setTimer (timeout_t timeout = 0)

setTimer

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:
timeoutin milliseconds.

Reimplemented from TimerPort.

void  incTimer (timeout_t timeout)

incTimer

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:
timeoutin milliseconds.

Reimplemented from TimerPort.