\section{ost::Socket\-Port Class Reference} \label{classost_1_1_socket_port}\index{ost::SocketPort@{ost::SocketPort}} The socket port is an internal class which is attached to and then serviced by a specific {\bf Socket\-Service}{\rm (p.\,\pageref{classost_1_1_socket_service})} \char`\"{}object\char`\"{}.base class for realtime and thread pool serviced protocols. {\tt \#include $<$socketport.h$>$} Inheritance diagram for ost::Socket\-Port::\begin{figure}[H] \begin{center} \leavevmode \includegraphics[height=2cm]{classost_1_1_socket_port} \end{center} \end{figure} \subsection*{Public Member Functions} \begin{CompactItemize} \item void {\bf set\-Timer} ({\bf timeout\_\-t} timeout=0) \begin{CompactList}\small\item\em Derived set\-Timer to notify the service thread pool of change in expected timeout. \item\end{CompactList}\item void {\bf inc\-Timer} ({\bf timeout\_\-t} timeout) \begin{CompactList}\small\item\em Derived inc\-Timer to notify the service thread pool of a change in expected timeout. \item\end{CompactList}\end{CompactItemize} \subsection*{Protected Member Functions} \begin{CompactItemize} \item {\bf Socket\-Port} ({\bf Socket\-Service} $\ast$svc, {\bf TCPSocket} \&tcp) \begin{CompactList}\small\item\em Construct an accepted TCP socket connection from a specific bound TCP server. \item\end{CompactList}\item {\bf Socket\-Port} ({\bf Socket\-Service} $\ast$svc, {\bf TCPV6Socket} \&tcp) \item {\bf Socket\-Port} ({\bf Socket\-Service} $\ast$svc, const {\bf IPV4Address} \&ia, {\bf tpport\_\-t} port) \begin{CompactList}\small\item\em Construct a bound UDP socket for use in deriving realtime UDP streaming protocols handled by thread pool objects. \item\end{CompactList}\item {\bf Socket\-Port} ({\bf Socket\-Service} $\ast$svc, const {\bf IPV6Address} \&ia, {\bf tpport\_\-t} port) \item {\bf Socket\-Port} ({\bf Socket\-Service} $\ast$svc, const {\bf IPV4Host} \&ih, {\bf tpport\_\-t} port) \begin{CompactList}\small\item\em A non-blocking constructor for outbound tcp connections. \item\end{CompactList}\item {\bf Socket\-Port} ({\bf Socket\-Service} $\ast$svc, const {\bf IPV6Host} \&ih, {\bf tpport\_\-t} port) \item void {\bf attach} ({\bf Socket\-Service} $\ast$svc) \begin{CompactList}\small\item\em Attach yourself to the service pool thread object. \item\end{CompactList}\item virtual {\bf $\sim$Socket\-Port} () \begin{CompactList}\small\item\em Disconnect the socket from the service thread pool and the remote connection. \item\end{CompactList}\item void {\bf set\-Detect\-Pending} (bool) \begin{CompactList}\small\item\em Used to indicate if the service thread should monitor pending data for us. \item\end{CompactList}\item bool {\bf get\-Detect\-Pending} (void) const \begin{CompactList}\small\item\em Get the current state of the Detect\-Pending flag. \item\end{CompactList}\item void {\bf set\-Detect\-Output} (bool) \begin{CompactList}\small\item\em Used to indicate if output ready monitoring should be performed by the service thread. \item\end{CompactList}\item bool {\bf get\-Detect\-Output} (void) const \begin{CompactList}\small\item\em Get the current state of the Detect\-Output flag. \item\end{CompactList}\item virtual void {\bf expired} (void) \begin{CompactList}\small\item\em Called by the service thread pool when the objects timer has expired. \item\end{CompactList}\item virtual void {\bf pending} (void) \begin{CompactList}\small\item\em Called by the service thread pool when input data is pending for this socket. \item\end{CompactList}\item virtual void {\bf output} (void) \begin{CompactList}\small\item\em Called by the service thread pool when output data is pending for this socket. \item\end{CompactList}\item virtual void {\bf disconnect} (void) \begin{CompactList}\small\item\em Called by the service thread pool when a disconnect has occured. \item\end{CompactList}\item {\bf Error} {\bf connect} (const {\bf IPV4Address} \&ia, {\bf tpport\_\-t} port) \begin{CompactList}\small\item\em Connect a {\bf Socket}{\rm (p.\,\pageref{classost_1_1_socket})} Port to a known peer host. \item\end{CompactList}\item {\bf Error} {\bf connect} (const {\bf IPV6Address} \&ia, {\bf tpport\_\-t} port) \item ssize\_\-t {\bf send} (const void $\ast$buf, size\_\-t len) \begin{CompactList}\small\item\em Transmit \char`\"{}send\char`\"{} data to a connected peer host. \item\end{CompactList}\item ssize\_\-t {\bf receive} (void $\ast$buf, size\_\-t len) \begin{CompactList}\small\item\em Receive a message from any host. \item\end{CompactList}\item ssize\_\-t {\bf peek} (void $\ast$buf, size\_\-t len) \begin{CompactList}\small\item\em Examine the content of the next packet. \item\end{CompactList}\end{CompactItemize} \subsection*{Friends} \begin{CompactItemize} \item class {\bf Socket\-Service} \end{CompactItemize} \subsection{Detailed Description} The socket port is an internal class which is attached to and then serviced by a specific {\bf Socket\-Service}{\rm (p.\,\pageref{classost_1_1_socket_service})} \char`\"{}object\char`\"{}.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, \char`\"{}Socket\-Port\char`\"{} and \char`\"{}Socket\-Service\char`\"{}, exist for building realtime streaming media servers on top of UDP and TCP protocols. The \char`\"{}Socket\-Port\char`\"{} is used to hold a connected or associated TCP or UDP socket which is being \char`\"{}streamed\char`\"{} and which offers callback methods that are invoked from a \char`\"{}Socket\-Service\char`\"{} thread. Socket\-Service's can be pooled into logical thread pools that can service a group of Socket\-Ports. A millisecond accurate \char`\"{}timer\char`\"{} is associated with each {\bf Socket\-Port}{\rm (p.\,\pageref{classost_1_1_socket_port})} and can be used to time synchronize {\bf Socket\-Port}{\rm (p.\,\pageref{classost_1_1_socket_port})} I/O operations. \begin{Desc} \item[Author:]David Sugar $<${\tt dyfet@ostel.com}$>$ \end{Desc} \begin{Desc} \item[Examples: ]\par {\bf tcpservice.cpp}.\end{Desc} \subsection{Constructor \& Destructor Documentation} \index{ost::SocketPort@{ost::Socket\-Port}!SocketPort@{SocketPort}} \index{SocketPort@{SocketPort}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Socket\-Port::Socket\-Port ({\bf Socket\-Service} $\ast$ {\em svc}, {\bf TCPSocket} \& {\em tcp})\hspace{0.3cm}{\tt [protected]}}\label{classost_1_1_socket_port_3e1456c5b19bb0dc58df0356c055709a} 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. \begin{Desc} \item[Parameters:] \begin{description} \item[{\em svc}]pool thread object. \item[{\em tcp}]socket object to accept. \end{description} \end{Desc} \index{ost::SocketPort@{ost::Socket\-Port}!SocketPort@{SocketPort}} \index{SocketPort@{SocketPort}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Socket\-Port::Socket\-Port ({\bf Socket\-Service} $\ast$ {\em svc}, {\bf TCPV6Socket} \& {\em tcp})\hspace{0.3cm}{\tt [protected]}}\label{classost_1_1_socket_port_edfa5983eefe7e5bca5b3f4c4752ef88} \index{ost::SocketPort@{ost::Socket\-Port}!SocketPort@{SocketPort}} \index{SocketPort@{SocketPort}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Socket\-Port::Socket\-Port ({\bf Socket\-Service} $\ast$ {\em svc}, const {\bf IPV4Address} \& {\em ia}, {\bf tpport\_\-t} {\em port})\hspace{0.3cm}{\tt [protected]}}\label{classost_1_1_socket_port_e48593fbe73189d452f62ac6864f832f} Construct a bound UDP socket for use in deriving realtime UDP streaming protocols handled by thread pool objects. \begin{Desc} \item[Parameters:] \begin{description} \item[{\em svc}]pool thread object. \item[{\em ia}]address of interface to bind. \item[{\em port}]number to bind to. \end{description} \end{Desc} \index{ost::SocketPort@{ost::Socket\-Port}!SocketPort@{SocketPort}} \index{SocketPort@{SocketPort}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Socket\-Port::Socket\-Port ({\bf Socket\-Service} $\ast$ {\em svc}, const {\bf IPV6Address} \& {\em ia}, {\bf tpport\_\-t} {\em port})\hspace{0.3cm}{\tt [protected]}}\label{classost_1_1_socket_port_df67a624a192a3eaffbf59891669b1bd} \index{ost::SocketPort@{ost::Socket\-Port}!SocketPort@{SocketPort}} \index{SocketPort@{SocketPort}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Socket\-Port::Socket\-Port ({\bf Socket\-Service} $\ast$ {\em svc}, const {\bf IPV4Host} \& {\em ih}, {\bf tpport\_\-t} {\em port})\hspace{0.3cm}{\tt [protected]}}\label{classost_1_1_socket_port_c30498e30cd95a8f91c395ebb6e6116a} A non-blocking constructor for outbound tcp connections. To detect when the connection is established, overload {\bf Socket\-Port::output()}{\rm (p.\,\pageref{classost_1_1_socket_port_f333abc3b9f8f8b2ce4d286d64d54848})}. {\bf Socket\-Port::output()}{\rm (p.\,\pageref{classost_1_1_socket_port_f333abc3b9f8f8b2ce4d286d64d54848})} get's called by the {\bf Socket\-Service}{\rm (p.\,\pageref{classost_1_1_socket_service})} when the connection is ready, {\bf Socket\-Port::disconnect()}{\rm (p.\,\pageref{classost_1_1_socket_port_7b2a739ee0cb11bc6332010f4cd21552})} when the connect failed. at the moment you should set the socket state to \char`\"{}CONNECTED\char`\"{} when {\bf Socket\-Port::output()}{\rm (p.\,\pageref{classost_1_1_socket_port_f333abc3b9f8f8b2ce4d286d64d54848})} get's called for the first time. \begin{Desc} \item[Parameters:] \begin{description} \item[{\em svc}]pool thread object. \item[{\em ih}]addess to connect to. \item[{\em port}]number to connect to. \end{description} \end{Desc} \index{ost::SocketPort@{ost::Socket\-Port}!SocketPort@{SocketPort}} \index{SocketPort@{SocketPort}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Socket\-Port::Socket\-Port ({\bf Socket\-Service} $\ast$ {\em svc}, const {\bf IPV6Host} \& {\em ih}, {\bf tpport\_\-t} {\em port})\hspace{0.3cm}{\tt [protected]}}\label{classost_1_1_socket_port_0aee0992af4ffdbda14489ef094a89fd} \index{ost::SocketPort@{ost::Socket\-Port}!~SocketPort@{$\sim$SocketPort}} \index{~SocketPort@{$\sim$SocketPort}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual ost::Socket\-Port::$\sim$Socket\-Port ()\hspace{0.3cm}{\tt [protected, virtual]}}\label{classost_1_1_socket_port_8c9fcdcd63fae060e12801ddf6ab12db} Disconnect the socket from the service thread pool and the remote connection. \subsection{Member Function Documentation} \index{ost::SocketPort@{ost::Socket\-Port}!attach@{attach}} \index{attach@{attach}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Socket\-Port::attach ({\bf Socket\-Service} $\ast$ {\em svc})\hspace{0.3cm}{\tt [protected]}}\label{classost_1_1_socket_port_ed5fbff0b874da8e24add7f6cc50b65e} Attach yourself to the service pool thread object. The later version. \begin{Desc} \item[Parameters:] \begin{description} \item[{\em svc}]pool thread object \end{description} \end{Desc} \begin{Desc} \item[Examples: ]\par {\bf tcpservice.cpp}.\end{Desc} \index{ost::SocketPort@{ost::Socket\-Port}!connect@{connect}} \index{connect@{connect}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Error} ost::Socket\-Port::connect (const {\bf IPV6Address} \& {\em ia}, {\bf tpport\_\-t} {\em port})\hspace{0.3cm}{\tt [protected]}}\label{classost_1_1_socket_port_0edb8c155c97099cc0660b3ad1eef77f} \index{ost::SocketPort@{ost::Socket\-Port}!connect@{connect}} \index{connect@{connect}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Error} ost::Socket\-Port::connect (const {\bf IPV4Address} \& {\em ia}, {\bf tpport\_\-t} {\em port})\hspace{0.3cm}{\tt [protected]}}\label{classost_1_1_socket_port_3601785c16646b7e323cf2d267ce7481} Connect a {\bf Socket}{\rm (p.\,\pageref{classost_1_1_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. \begin{Desc} \item[Returns:]0 if successful. \end{Desc} \begin{Desc} \item[Parameters:] \begin{description} \item[{\em ia}]address of remote host or subnet. \item[{\em port}]number of remote peer(s). \end{description} \end{Desc} \index{ost::SocketPort@{ost::Socket\-Port}!disconnect@{disconnect}} \index{disconnect@{disconnect}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual void ost::Socket\-Port::disconnect (void)\hspace{0.3cm}{\tt [protected, virtual]}}\label{classost_1_1_socket_port_7b2a739ee0cb11bc6332010f4cd21552} Called by the service thread pool when a disconnect has occured. \index{ost::SocketPort@{ost::Socket\-Port}!expired@{expired}} \index{expired@{expired}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual void ost::Socket\-Port::expired (void)\hspace{0.3cm}{\tt [protected, virtual]}}\label{classost_1_1_socket_port_4d09daed3fe5cb81259985db87add34d} Called by the service thread pool when the objects timer has expired. Used for timed events. \begin{Desc} \item[Examples: ]\par {\bf tcpservice.cpp}.\end{Desc} \index{ost::SocketPort@{ost::Socket\-Port}!getDetectOutput@{getDetectOutput}} \index{getDetectOutput@{getDetectOutput}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool ost::Socket\-Port::get\-Detect\-Output (void) const\hspace{0.3cm}{\tt [inline, protected]}}\label{classost_1_1_socket_port_80a16072f163a5a49341c4fd495fd9b1} Get the current state of the Detect\-Output flag. \index{ost::SocketPort@{ost::Socket\-Port}!getDetectPending@{getDetectPending}} \index{getDetectPending@{getDetectPending}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool ost::Socket\-Port::get\-Detect\-Pending (void) const\hspace{0.3cm}{\tt [inline, protected]}}\label{classost_1_1_socket_port_f1e65f719e39f651ad8789183f8905c9} Get the current state of the Detect\-Pending flag. \index{ost::SocketPort@{ost::Socket\-Port}!incTimer@{incTimer}} \index{incTimer@{incTimer}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Socket\-Port::inc\-Timer ({\bf timeout\_\-t} {\em timeout})}\label{classost_1_1_socket_port_1a7e2bf9e250ea5dcc9e8416aecfbb13} Derived inc\-Timer to notify the service thread pool of a change in expected timeout. This allows {\bf Socket\-Service}{\rm (p.\,\pageref{classost_1_1_socket_service})} to reschedule all timers. Otherwise same as {\bf Timer\-Port}{\rm (p.\,\pageref{classost_1_1_timer_port})}. \begin{Desc} \item[Parameters:] \begin{description} \item[{\em timeout}]in milliseconds. \end{description} \end{Desc} Reimplemented from {\bf ost::Timer\-Port} {\rm (p.\,\pageref{classost_1_1_timer_port_b2c732120c3bb09e8d38a87b7443906d})}.\index{ost::SocketPort@{ost::Socket\-Port}!output@{output}} \index{output@{output}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual void ost::Socket\-Port::output (void)\hspace{0.3cm}{\tt [protected, virtual]}}\label{classost_1_1_socket_port_f333abc3b9f8f8b2ce4d286d64d54848} Called by the service thread pool when output data is pending for this socket. \index{ost::SocketPort@{ost::Socket\-Port}!peek@{peek}} \index{peek@{peek}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}ssize\_\-t ost::Socket\-Port::peek (void $\ast$ {\em buf}, size\_\-t {\em len})\hspace{0.3cm}{\tt [inline, protected]}}\label{classost_1_1_socket_port_fb7798f8cc7e50d42ad82a1537e89c63} Examine the content of the next packet. This can be used to build \char`\"{}smart\char`\"{} line buffering for derived TCP classes. \begin{Desc} \item[Parameters:] \begin{description} \item[{\em buf}]pointer to packet buffer to examine. \item[{\em len}]of packet buffer to examine. \end{description} \end{Desc} \begin{Desc} \item[Returns:]number of bytes actually available. \end{Desc} \index{ost::SocketPort@{ost::Socket\-Port}!pending@{pending}} \index{pending@{pending}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual void ost::Socket\-Port::pending (void)\hspace{0.3cm}{\tt [protected, virtual]}}\label{classost_1_1_socket_port_5e0ec242cfb737db369cbc63abcc06b6} Called by the service thread pool when input data is pending for this socket. \begin{Desc} \item[Examples: ]\par {\bf tcpservice.cpp}.\end{Desc} \index{ost::SocketPort@{ost::Socket\-Port}!receive@{receive}} \index{receive@{receive}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}ssize\_\-t ost::Socket\-Port::receive (void $\ast$ {\em buf}, size\_\-t {\em len})\hspace{0.3cm}{\tt [inline, protected]}}\label{classost_1_1_socket_port_872c38a65b17113a580af345946146d7} Receive a message from any host. This is used in derived classes to build protocols. \begin{Desc} \item[Parameters:] \begin{description} \item[{\em buf}]pointer to packet buffer to receive. \item[{\em len}]of packet buffer to receive. \end{description} \end{Desc} \begin{Desc} \item[Returns:]number of bytes received. \end{Desc} \begin{Desc} \item[Examples: ]\par {\bf tcpservice.cpp}.\end{Desc} \index{ost::SocketPort@{ost::Socket\-Port}!send@{send}} \index{send@{send}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}ssize\_\-t ost::Socket\-Port::send (const void $\ast$ {\em buf}, size\_\-t {\em len})\hspace{0.3cm}{\tt [inline, protected]}}\label{classost_1_1_socket_port_9218e4528f5bdf4215200e2040eefe5b} Transmit \char`\"{}send\char`\"{} 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. \begin{Desc} \item[Returns:]number of bytes sent. \end{Desc} \begin{Desc} \item[Parameters:] \begin{description} \item[{\em buf}]address of buffer to send. \item[{\em len}]of bytes to send. \end{description} \end{Desc} \begin{Desc} \item[Examples: ]\par {\bf tcpservice.cpp}.\end{Desc} \index{ost::SocketPort@{ost::Socket\-Port}!setDetectOutput@{setDetectOutput}} \index{setDetectOutput@{setDetectOutput}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Socket\-Port::set\-Detect\-Output (bool)\hspace{0.3cm}{\tt [protected]}}\label{classost_1_1_socket_port_229b32cb2bf8a306b8882413748eb44c} Used to indicate if output ready monitoring should be performed by the service thread. \index{ost::SocketPort@{ost::Socket\-Port}!setDetectPending@{setDetectPending}} \index{setDetectPending@{setDetectPending}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Socket\-Port::set\-Detect\-Pending (bool)\hspace{0.3cm}{\tt [protected]}}\label{classost_1_1_socket_port_908891c78c95d66424cde91e52299c29} Used to indicate if the service thread should monitor pending data for us. \index{ost::SocketPort@{ost::Socket\-Port}!setTimer@{setTimer}} \index{setTimer@{setTimer}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Socket\-Port::set\-Timer ({\bf timeout\_\-t} {\em timeout} = {\tt 0})}\label{classost_1_1_socket_port_c70f9eae6b6b3625c980fa84180e8151} Derived set\-Timer to notify the service thread pool of change in expected timeout. This allows {\bf Socket\-Service}{\rm (p.\,\pageref{classost_1_1_socket_service})} to reschedule all timers. Otherwise same as {\bf Timer\-Port}{\rm (p.\,\pageref{classost_1_1_timer_port})}. \begin{Desc} \item[Parameters:] \begin{description} \item[{\em timeout}]in milliseconds. \end{description} \end{Desc} Reimplemented from {\bf ost::Timer\-Port} {\rm (p.\,\pageref{classost_1_1_timer_port_32b59a072fe60d94251a53579b3ca17f})}.\begin{Desc} \item[Examples: ]\par {\bf tcpservice.cpp}.\end{Desc} \subsection{Friends And Related Function Documentation} \index{ost::SocketPort@{ost::Socket\-Port}!SocketService@{SocketService}} \index{SocketService@{SocketService}!ost::SocketPort@{ost::Socket\-Port}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}friend class {\bf Socket\-Service}\hspace{0.3cm}{\tt [friend]}}\label{classost_1_1_socket_port_4b89563fb4861da0276ccd214f93122d} The documentation for this class was generated from the following file:\begin{CompactItemize} \item {\bf socketport.h}\end{CompactItemize}