Sophie

Sophie

distrib > Mandriva > 2007.0 > i586 > by-pkgid > ad1ba1135a9c9eeffc2e538163e00373 > files > 772

libCommonC++2_1.4-devel-1.4.1-1mdv2007.0.i586.rpm

\section{ost::TCPSocket Class Reference}
\label{classost_1_1_t_c_p_socket}\index{ost::TCPSocket@{ost::TCPSocket}}
TCP sockets are used for stream based connected sessions between two sockets.bound server for TCP streams and sessions.  


{\tt \#include $<$socket.h$>$}

Inheritance diagram for ost::TCPSocket::\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2cm]{classost_1_1_t_c_p_socket}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
virtual bool {\bf on\-Accept} (const {\bf IPV4Host} \&ia, {\bf tpport\_\-t} port)
\begin{CompactList}\small\item\em A method to call in a derived {\bf TCPSocket}{\rm (p.\,\pageref{classost_1_1_t_c_p_socket})} class that is acting as a server when a connection request is being accepted. \item\end{CompactList}\item 
{\bf SOCKET} {\bf get\-Socket} (void)
\begin{CompactList}\small\item\em Fetch out the socket. \item\end{CompactList}\item 
int {\bf get\-Segment\-Size} (void)
\begin{CompactList}\small\item\em Get the buffer size for servers. \item\end{CompactList}\item 
{\bf TCPSocket} (const {\bf IPV4Address} \&bind, {\bf tpport\_\-t} port, unsigned backlog=5, unsigned mss=536)
\begin{CompactList}\small\item\em A TCP \char`\"{}server\char`\"{} is created as a TCP socket that is bound to a hardware address and port number on the local machine and that has a backlog queue to listen for remote connection requests. \item\end{CompactList}\item 
{\bf TCPSocket} (const char $\ast$name, unsigned backlog=5, unsigned mss=536)
\begin{CompactList}\small\item\em Create a named tcp socket by service and/or interface id. \item\end{CompactList}\item 
{\bf IPV4Host} {\bf get\-Request} ({\bf tpport\_\-t} $\ast$port=NULL) const 
\begin{CompactList}\small\item\em Return address and port of next connection request. \item\end{CompactList}\item 
void {\bf reject} (void)
\begin{CompactList}\small\item\em Used to reject the next incoming connection request. \item\end{CompactList}\item 
{\bf IPV4Host} {\bf get\-Local} ({\bf tpport\_\-t} $\ast$port=NULL) const 
\begin{CompactList}\small\item\em Used to get local bound address. \item\end{CompactList}\item 
bool {\bf is\-Pending\-Connection} ({\bf timeout\_\-t} timeout=TIMEOUT\_\-INF)
\begin{CompactList}\small\item\em Used to wait for pending connection requests. \item\end{CompactList}\item 
virtual {\bf $\sim$TCPSocket} ()
\begin{CompactList}\small\item\em Use base socket handler for ending this socket. \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
void {\bf set\-Segment\-Size} (unsigned mss)
\end{CompactItemize}
\subsection*{Protected Attributes}
\begin{CompactItemize}
\item 
int {\bf segsize}
\end{CompactItemize}


\subsection{Detailed Description}
TCP sockets are used for stream based connected sessions between two sockets.bound server for TCP streams and sessions. 

Both error recovery and flow control operate transparently for a TCP socket connection. The TCP socket base class is primary used to bind a TCP \char`\"{}server\char`\"{} for accepting TCP streams.

An implicit and unique {\bf TCPSocket}{\rm (p.\,\pageref{classost_1_1_t_c_p_socket})} object exists in Common C++ to represent a bound TCP socket acting as a \char`\"{}server\char`\"{} for receiving connection requests. This class is not part of {\bf TCPStream}{\rm (p.\,\pageref{classost_1_1_t_c_p_stream})} because such objects normally perform no physical I/O (read or write operations) other than to specify a listen backlog queue and perform \char`\"{}accept\char`\"{} operations for pending connections. The Common C++ {\bf TCPSocket}{\rm (p.\,\pageref{classost_1_1_t_c_p_socket})} offers a Peek method to examine where the next pending connection is coming from, and a Reject method to flush the next request from the queue without having to create a session.

The {\bf TCPSocket}{\rm (p.\,\pageref{classost_1_1_t_c_p_socket})} also supports a \char`\"{}On\-Accept\char`\"{} method which can be called when a {\bf TCPStream}{\rm (p.\,\pageref{classost_1_1_t_c_p_stream})} related object is created from a {\bf TCPSocket}{\rm (p.\,\pageref{classost_1_1_t_c_p_socket})}. By creating a {\bf TCPStream}{\rm (p.\,\pageref{classost_1_1_t_c_p_stream})} from a {\bf TCPSocket}{\rm (p.\,\pageref{classost_1_1_t_c_p_socket})}, an accept operation automatically occurs, and the {\bf TCPSocket}{\rm (p.\,\pageref{classost_1_1_t_c_p_socket})} can then still reject the client connection through the return status of it's On\-Accept method.

\begin{Desc}
\item[Author:]David Sugar $<${\tt dyfet@tycho.com}$>$ \end{Desc}
\begin{Desc}
\item[Examples: ]\par


{\bf tcp.cpp}, {\bf tcpservice.cpp}, {\bf tcpstr1.cpp}, and {\bf tcpthread.cpp}.\end{Desc}




\subsection{Constructor \& Destructor Documentation}
\index{ost::TCPSocket@{ost::TCPSocket}!TCPSocket@{TCPSocket}}
\index{TCPSocket@{TCPSocket}!ost::TCPSocket@{ost::TCPSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::TCPSocket::TCPSocket (const {\bf IPV4Address} \& {\em bind}, {\bf tpport\_\-t} {\em port}, unsigned {\em backlog} = {\tt 5}, unsigned {\em mss} = {\tt 536})}\label{classost_1_1_t_c_p_socket_8d86e9b2df64e14b4aebe9cd38903c73}


A TCP \char`\"{}server\char`\"{} is created as a TCP socket that is bound to a hardware address and port number on the local machine and that has a backlog queue to listen for remote connection requests. 

If the server cannot be created, an exception is thrown.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em bind}]local ip address or interface to use. \item[{\em port}]number to bind socket under. \item[{\em backlog}]size of connection request queue. \item[{\em mss}]maximum segment size for accepted streams. \end{description}
\end{Desc}
\index{ost::TCPSocket@{ost::TCPSocket}!TCPSocket@{TCPSocket}}
\index{TCPSocket@{TCPSocket}!ost::TCPSocket@{ost::TCPSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::TCPSocket::TCPSocket (const char $\ast$ {\em name}, unsigned {\em backlog} = {\tt 5}, unsigned {\em mss} = {\tt 536})}\label{classost_1_1_t_c_p_socket_94e6b4e3dc2906799ea2fa7367c7eadb}


Create a named tcp socket by service and/or interface id. 

For IPV4 we use [host:]svc or [host/]svc for the string. If we have getaddrinfo, we use that to obtain the addr to bind for.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em name}]of host interface and service port to bind. \item[{\em backlog}]size of connection request queue. \item[{\em mss}]maximum segment size for streaming buffers. \end{description}
\end{Desc}
\index{ost::TCPSocket@{ost::TCPSocket}!~TCPSocket@{$\sim$TCPSocket}}
\index{~TCPSocket@{$\sim$TCPSocket}!ost::TCPSocket@{ost::TCPSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual ost::TCPSocket::$\sim$TCPSocket ()\hspace{0.3cm}{\tt  [virtual]}}\label{classost_1_1_t_c_p_socket_64201dd76b9d05cba0ea2db73b4bdd6b}


Use base socket handler for ending this socket. 



\subsection{Member Function Documentation}
\index{ost::TCPSocket@{ost::TCPSocket}!getLocal@{getLocal}}
\index{getLocal@{getLocal}!ost::TCPSocket@{ost::TCPSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf IPV4Host} ost::TCPSocket::get\-Local ({\bf tpport\_\-t} $\ast$ {\em port} = {\tt NULL}) const\hspace{0.3cm}{\tt  [inline]}}\label{classost_1_1_t_c_p_socket_a0779bf0973ae5b54a5f323ef62ab4ae}


Used to get local bound address. 



Reimplemented from {\bf ost::Socket} {\rm (p.\,\pageref{classost_1_1_socket_ca71d871bfda4dfcab0891cb0c8df1d4})}.\index{ost::TCPSocket@{ost::TCPSocket}!getRequest@{getRequest}}
\index{getRequest@{getRequest}!ost::TCPSocket@{ost::TCPSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf IPV4Host} ost::TCPSocket::get\-Request ({\bf tpport\_\-t} $\ast$ {\em port} = {\tt NULL}) const\hspace{0.3cm}{\tt  [inline]}}\label{classost_1_1_t_c_p_socket_bb20f4723de2e9641528d9c82f9389d1}


Return address and port of next connection request. 

This can be used instead of On\-Accept() to pre-evaluate connection requests.

\begin{Desc}
\item[Returns:]host requesting a connection. \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em port}]number of requestor. \end{description}
\end{Desc}
\index{ost::TCPSocket@{ost::TCPSocket}!getSegmentSize@{getSegmentSize}}
\index{getSegmentSize@{getSegmentSize}!ost::TCPSocket@{ost::TCPSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int ost::TCPSocket::get\-Segment\-Size (void)\hspace{0.3cm}{\tt  [inline]}}\label{classost_1_1_t_c_p_socket_e25df03dd4c3abd8da25e20a59ffbc62}


Get the buffer size for servers. 

\index{ost::TCPSocket@{ost::TCPSocket}!getSocket@{getSocket}}
\index{getSocket@{getSocket}!ost::TCPSocket@{ost::TCPSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf SOCKET} ost::TCPSocket::get\-Socket (void)\hspace{0.3cm}{\tt  [inline]}}\label{classost_1_1_t_c_p_socket_58d0e49f75856b2e888e9ac894c489a2}


Fetch out the socket. 

\index{ost::TCPSocket@{ost::TCPSocket}!isPendingConnection@{isPendingConnection}}
\index{isPendingConnection@{isPendingConnection}!ost::TCPSocket@{ost::TCPSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool ost::TCPSocket::is\-Pending\-Connection ({\bf timeout\_\-t} {\em timeout} = {\tt TIMEOUT\_\-INF})\hspace{0.3cm}{\tt  [inline]}}\label{classost_1_1_t_c_p_socket_112e8235b317f15e15f6ea264fe81eb7}


Used to wait for pending connection requests. 

\begin{Desc}
\item[Returns:]true if data packets available. \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em timeout}]in milliseconds. TIMEOUT\_\-INF if not specified. \end{description}
\end{Desc}
\begin{Desc}
\item[Examples: ]\par
{\bf tcpstr1.cpp}, and {\bf tcpthread.cpp}.\end{Desc}
\index{ost::TCPSocket@{ost::TCPSocket}!onAccept@{onAccept}}
\index{onAccept@{onAccept}!ost::TCPSocket@{ost::TCPSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual bool ost::TCPSocket::on\-Accept (const {\bf IPV4Host} \& {\em ia}, {\bf tpport\_\-t} {\em port})\hspace{0.3cm}{\tt  [virtual]}}\label{classost_1_1_t_c_p_socket_8ba3a6ecd27ab319e83bb6445828f7ef}


A method to call in a derived {\bf TCPSocket}{\rm (p.\,\pageref{classost_1_1_t_c_p_socket})} class that is acting as a server when a connection request is being accepted. 

The server can implement protocol specific rules to exclude the remote socket from being accepted by returning false. The Peek method can also be used for this purpose.

\begin{Desc}
\item[Returns:]true if client should be accepted. \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ia}]internet host address of the client. \item[{\em port}]number of the client. \end{description}
\end{Desc}
\begin{Desc}
\item[Examples: ]\par
{\bf tcp.cpp}, and {\bf tcpthread.cpp}.\end{Desc}
\index{ost::TCPSocket@{ost::TCPSocket}!reject@{reject}}
\index{reject@{reject}!ost::TCPSocket@{ost::TCPSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::TCPSocket::reject (void)}\label{classost_1_1_t_c_p_socket_22c104eee3b3494189754f25f1d7075e}


Used to reject the next incoming connection request. 

\index{ost::TCPSocket@{ost::TCPSocket}!setSegmentSize@{setSegmentSize}}
\index{setSegmentSize@{setSegmentSize}!ost::TCPSocket@{ost::TCPSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::TCPSocket::set\-Segment\-Size (unsigned {\em mss})\hspace{0.3cm}{\tt  [protected]}}\label{classost_1_1_t_c_p_socket_7dc58365b578003db6679097965ef42c}




\subsection{Member Data Documentation}
\index{ost::TCPSocket@{ost::TCPSocket}!segsize@{segsize}}
\index{segsize@{segsize}!ost::TCPSocket@{ost::TCPSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int {\bf ost::TCPSocket::segsize}\hspace{0.3cm}{\tt  [protected]}}\label{classost_1_1_t_c_p_socket_926afdde97f8074cfe21a6c0d23830ed}




The documentation for this class was generated from the following file:\begin{CompactItemize}
\item 
{\bf socket.h}\end{CompactItemize}