ost::SocketPort(3)
π NAME π
ost::SocketPort β bestie, this is the socket port, and it's an internal class which is attached to and then serviced by a specific SocketService 'object'. That's the whole vibe. π«Ά
β¨ SYNOPSIS β¨
#include <socketport.h>
It inherits ost::Socket, and ost::TimerPort. Two parents, one icon. π
π Public Member Functions
void setTimer (timeout_t timeout=0)β a derivedsetTimerthat pings the service thread pool that the expected timeout changed.void incTimer (timeout_t timeout)β a derivedincTimer, same deal, telling the service thread pool the expected timeout shifted.
π Protected Member Functions
SocketPort (SocketService *svc, TCPSocket &tcp)β builds an accepted TCP socket connection from a specific bound TCP server.SocketPort (SocketService *svc, TCPV6Socket &tcp)SocketPort (SocketService *svc, const IPV4Address &ia, tpport_t port)β builds a bound UDP socket, so you can derive realtime UDP streaming protocols that thread pool objects handle.SocketPort (SocketService *svc, const IPV6Address &ia, tpport_t port)SocketPort (SocketService *svc, const IPV4Host &ih, tpport_t port)β a non-blocking constructor for outbound tcp connections.SocketPort (SocketService *svc, const IPV6Host &ih, tpport_t port)void attach (SocketService *svc)β attach yourself to the service pool thread object.virtual ~SocketPort ()β disconnect the socket from the service thread pool and the remote connection.void setDetectPending (bool)β says whether the service thread should monitor pending data for us.bool getDetectPending (void) constβ grabs the current state of theDetectPendingflag.void setDetectOutput (bool)β says whether output ready monitoring should be done by the service thread.bool getDetectOutput (void) constβ grabs the current state of theDetectOutputflag.virtual void expired (void)β called by the service thread pool when the object's timer has expired.virtual void pending (void)β called by the service thread pool when input data is pending for this socket.virtual void output (void)β called by the service thread pool when output data is pending for this socket.virtual void disconnect (void)β called by the service thread pool when a disconnect has occured.Error connect (const IPV4Address &ia, tpport_t port)β connect a Socket Port to a known peer host.Error connect (const IPV6Address &ia, tpport_t port)ssize_t send (const void *buf, size_t len)β transmit 'send' data to a connected peer host.ssize_t receive (void *buf, size_t len)β receive a message from any host.ssize_t peek (void *buf, size_t len)β examine the content of the next packet.
π« Friends
class SocketService
𧬠Additional Inherited Members
π Detailed Description π
The socket port is an internal class which is attached to and then serviced by a specific SocketService 'object'. (Yes, it's the NAME section again, she's an icon, she gets a second entrance. β¨)
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.
πΈ Author
David Sugar dyfet@ostel.com
base class for realtime and thread pool serviced protocols.
π Examples
tcpservice.cpp.
π Constructor & Destructor Documentation π
ost::SocketPort::SocketPort (SocketService * svc, TCPSocket & tcp)
[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
- svc β pool thread object.
- tcp β socket object to accept.
ost::SocketPort::SocketPort (SocketService * svc, TCPV6Socket & tcp)
[protected]
ost::SocketPort::SocketPort (SocketService * svc, const IPV4Address & ia, tpport_t port)
[protected]
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.
ost::SocketPort::SocketPort (SocketService * svc, const IPV6Address & ia, tpport_t port)
[protected]
ost::SocketPort::SocketPort (SocketService * svc, const IPV4Host & ih, tpport_t port)
[protected]
A non-blocking constructor for outbound tcp connections. To detect when the connection is established, overload SocketPort::output(). SocketPort::output() get's called by the SocketService when the connection is ready, SocketPort::disconnect() when the connect failed. at the moment you should set the socket state to 'CONNECTED' when SocketPort::output() get's called for the first time.
Parameters
- svc β pool thread object.
- ih β addess to connect to.
- port β number to connect to.
ost::SocketPort::SocketPort (SocketService * svc, const IPV6Host & ih, tpport_t port)
[protected]
virtual ost::SocketPort::~SocketPort ()
[protected], [virtual]
Disconnect the socket from the service thread pool and the remote connection. It's giving graceful exit. π
π¦ Member Function Documentation π¦
void ost::SocketPort::attach (SocketService * svc)
[protected]
Attach yourself to the service pool thread object. The later version.
Parameters
- svc β pool thread object
Error ost::SocketPort::connect (const IPV4Address & ia, tpport_t port)
[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.
Returns
0 if successful.
Parameters
- ia β address of remote host or subnet.
- port β number of remote peer(s).
Error ost::SocketPort::connect (const IPV6Address & ia, tpport_t port)
[protected]
virtual void ost::SocketPort::disconnect (void)
[protected], [virtual]
Called by the service thread pool when a disconnect has occured.
virtual void ost::SocketPort::expired (void)
[protected], [virtual]
Called by the service thread pool when the objects timer has expired. Used for timed events. β°
bool ost::SocketPort::getDetectOutput (void) const
[inline], [protected]
Get the current state of the DetectOutput flag.
bool ost::SocketPort::getDetectPending (void) const
[inline], [protected]
Get the current state of the DetectPending flag.
void ost::SocketPort::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.
virtual void ost::SocketPort::output (void)
[protected], [virtual]
Called by the service thread pool when output data is pending for this socket.
ssize_t ost::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
- buf β pointer to packet buffer to examine.
- len β of packet buffer to examine.
Returns
number of bytes actually available.
References
_IOLEN64.
virtual void ost::SocketPort::pending (void)
[protected], [virtual]
Called by the service thread pool when input data is pending for this socket.
ssize_t ost::SocketPort::receive (void * buf, size_t len)
[inline], [protected]
Receive a message from any host. This is used in derived classes to build protocols.
Parameters
- buf β pointer to packet buffer to receive.
- len β of packet buffer to receive.
Returns
number of bytes received.
References
_IOLEN64.
ssize_t ost::SocketPort::send (const void * buf, size_t 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.
Returns
number of bytes sent.
Parameters
- buf β address of buffer to send.
- len β of bytes to send.
References
_IOLEN64.
void ost::SocketPort::setDetectOutput (bool)
[protected]
Used to indicate if output ready monitoring should be performed by the service thread.
void ost::SocketPort::setDetectPending (bool)
[protected]
Used to indicate if the service thread should monitor pending data for us.
void ost::SocketPort::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.
π«Ά Friends And Related Function Documentation π«Ά
friend class SocketService
[friend]
π Author π
Generated automatically by Doxygen for GNU CommonC++ from the source code.
okay that's the whole page bestie, no skips, no summaries, every single flag and parameter accounted for, we ate and left no crumbs πβ¨
This was brought to you by GNU CommonC++, dated Sun Dec 27 2020, and if you need to cite it, it's ost::SocketPort(3) from the Library Functions Manual. mwah ππ
π¦
π¦ where this page comes from
- ubuntu jammy: libcommoncpp2-doc 1.8.1-10
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms