\hypertarget{classSocketClient}{
\section{SocketClient Class Reference}
\label{classSocketClient}\index{SocketClient@{SocketClient}}
}
Inheritance diagram for SocketClient:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classSocketClient}
\end{center}
\end{figure}
\subsection*{Public Types}
\begin{DoxyCompactItemize}
\item 
enum {\bfseries Event} \{ {\bfseries DATA} =  AsyncFileWriter::DATA, 
{\bfseries FLUSHING} =  AsyncFileWriter::FLUSHING, 
{\bfseries ERROR} =  AsyncFileWriter::OS\_\-ERROR
 \}
\item 
\hypertarget{classSocketClient_a80fca2c612913e2ec8e2c68440b7e3ee}{
typedef XorpCallback1$<$ void, bool $>$::RefPtr \hyperlink{classSocketClient_a80fca2c612913e2ec8e2c68440b7e3ee}{ConnectCallback}}
\label{classSocketClient_a80fca2c612913e2ec8e2c68440b7e3ee}

\begin{DoxyCompactList}\small\item\em Callback for connection attempts. \item\end{DoxyCompactList}\item 
typedef XorpCallback4$<$ bool, \hyperlink{classBGPPacket_a7558c3d07c1ac60abf3253e012964147}{BGPPacket::Status}, const uint8\_\-t $\ast$, size\_\-t, \hyperlink{classSocketClient}{SocketClient} $\ast$ $>$::RefPtr \hyperlink{classSocketClient_a928e364d34b6b010a810e6c7ab8054af}{MessageCallback}
\begin{DoxyCompactList}\small\item\em Callback for incoming data. \item\end{DoxyCompactList}\item 
typedef XorpCallback2$<$ void, Event, const uint8\_\-t $\ast$ $>$::RefPtr \hyperlink{classSocketClient_aee21e26f27f4953a97a2c7dbcbc9c5dd}{SendCompleteCallback}
\begin{DoxyCompactList}\small\item\em Callback for data transmission. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classSocketClient_ac0f25d386dde4beb367d9be36e8807f3}{SocketClient} (const \hyperlink{classIptuple}{Iptuple} \&iptuple, \hyperlink{classEventLoop}{EventLoop} \&e, bool md5sig=false)
\item 
void \hyperlink{classSocketClient_a98e6deea5575e90bd1016039e4e2e93d}{connect} (\hyperlink{classSocketClient_a80fca2c612913e2ec8e2c68440b7e3ee}{ConnectCallback} cb)
\begin{DoxyCompactList}\small\item\em Asynchronously connect. \item\end{DoxyCompactList}\item 
void \hyperlink{classSocketClient_a1ebc6316eb6b4b912e7e67ebc025853a}{connect\_\-break} ()
\begin{DoxyCompactList}\small\item\em Break asynchronous connect attempt. \item\end{DoxyCompactList}\item 
void \hyperlink{classSocketClient_af30125c7ab70276b5c576214b108a045}{connected} (\hyperlink{classXorpFd}{XorpFd} s)
\begin{DoxyCompactList}\small\item\em The peer has initiated \hyperlink{protocolthe-p}{the} connection so form an association. \item\end{DoxyCompactList}\item 
\hypertarget{classSocketClient_a9cc57c0f48a4cbabaaa2a74c1340a4f4}{
void \hyperlink{classSocketClient_a9cc57c0f48a4cbabaaa2a74c1340a4f4}{flush\_\-transmit\_\-queue} ()}
\label{classSocketClient_a9cc57c0f48a4cbabaaa2a74c1340a4f4}

\begin{DoxyCompactList}\small\item\em Throw away all \hyperlink{protocolthe-p}{the} data that is queued to be sent on this socket. \item\end{DoxyCompactList}\item 
\hypertarget{classSocketClient_ab25fcc1fb90f2cc895b5a235bf191a16}{
void \hyperlink{classSocketClient_ab25fcc1fb90f2cc895b5a235bf191a16}{stop\_\-reader} ()}
\label{classSocketClient_ab25fcc1fb90f2cc895b5a235bf191a16}

\begin{DoxyCompactList}\small\item\em Stop reading data on this socket. \item\end{DoxyCompactList}\item 
\hypertarget{classSocketClient_a94882928a0fdca552a42260a8d8c7a69}{
void \hyperlink{classSocketClient_a94882928a0fdca552a42260a8d8c7a69}{disconnect} ()}
\label{classSocketClient_a94882928a0fdca552a42260a8d8c7a69}

\begin{DoxyCompactList}\small\item\em Disconnect this socket. \item\end{DoxyCompactList}\item 
bool \hyperlink{classSocketClient_a13ec024c8c25391a9749608316021544}{disconnecting} ()
\item 
\hypertarget{classSocketClient_aef03f1ff85e5cb725c7da07e4962746a}{
void \hyperlink{classSocketClient_aef03f1ff85e5cb725c7da07e4962746a}{set\_\-callback} (const \hyperlink{classSocketClient_a928e364d34b6b010a810e6c7ab8054af}{MessageCallback} \&cb)}
\label{classSocketClient_aef03f1ff85e5cb725c7da07e4962746a}

\begin{DoxyCompactList}\small\item\em Set \hyperlink{protocolthe-p}{the} callback for incoming data. \item\end{DoxyCompactList}\item 
bool \hyperlink{classSocketClient_a9639a4654eddb497beb9f6bc5fa4917c}{send\_\-message} (const uint8\_\-t $\ast$buf, size\_\-t cnt, \hyperlink{classSocketClient_aee21e26f27f4953a97a2c7dbcbc9c5dd}{SendCompleteCallback} cb)
\begin{DoxyCompactList}\small\item\em Asynchronously \hyperlink{structSend}{Send} a message. \item\end{DoxyCompactList}\item 
bool \hyperlink{classSocketClient_adda9f83279c46819a6c58db894cbb809}{output\_\-queue\_\-busy} () const 
\begin{DoxyCompactList}\small\item\em Flow control signal. \item\end{DoxyCompactList}\item 
int \hyperlink{classSocketClient_a5a7f1f592bf355a900e838dbd1952112}{output\_\-queue\_\-size} () const 
\item 
bool \hyperlink{classSocketClient_a4b1251cb08b51b1239a2b8796aba5b4a}{is\_\-connected} ()
\item 
bool \hyperlink{classSocketClient_a92a500fff1dcaabf20f49209d79341ac}{still\_\-reading} ()
\end{DoxyCompactItemize}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classSocketClient_a6ce9c8279da64d024ae7b90bed34552e}{
void {\bfseries connect\_\-socket} (\hyperlink{classXorpFd}{XorpFd} sock, string raddr, uint16\_\-t port, string laddr, \hyperlink{classSocketClient_a80fca2c612913e2ec8e2c68440b7e3ee}{ConnectCallback} cb)}
\label{classSocketClient_a6ce9c8279da64d024ae7b90bed34552e}

\item 
\hypertarget{classSocketClient_a4daefc796839ff5ebef8ab5c7f756c7c}{
void {\bfseries connect\_\-socket\_\-complete} (\hyperlink{classXorpFd}{XorpFd} fd, IoEventType type, \hyperlink{classSocketClient_a80fca2c612913e2ec8e2c68440b7e3ee}{ConnectCallback} cb)}
\label{classSocketClient_a4daefc796839ff5ebef8ab5c7f756c7c}

\item 
\hypertarget{classSocketClient_a2508de31f9de26d6f14ef2add7fce8f8}{
void {\bfseries connect\_\-socket\_\-break} ()}
\label{classSocketClient_a2508de31f9de26d6f14ef2add7fce8f8}

\item 
\hypertarget{classSocketClient_a4084db7922db2ae1fc8e7b8d871d43ba}{
void {\bfseries async\_\-add} (\hyperlink{classXorpFd}{XorpFd} sock)}
\label{classSocketClient_a4084db7922db2ae1fc8e7b8d871d43ba}

\item 
\hypertarget{classSocketClient_aa6fdb4e9e9c5d184da82c9656fbbddd3}{
void {\bfseries async\_\-remove} ()}
\label{classSocketClient_aa6fdb4e9e9c5d184da82c9656fbbddd3}

\item 
\hypertarget{classSocketClient_a6b8daf44291f3bed159212abdef84ae5}{
void {\bfseries async\_\-remove\_\-reader} ()}
\label{classSocketClient_a6b8daf44291f3bed159212abdef84ae5}

\item 
\hypertarget{classSocketClient_a874ef2983a9f04436cadbc34e12b4911}{
void {\bfseries read\_\-from\_\-server} (\hyperlink{classXorpFd}{XorpFd} sock)}
\label{classSocketClient_a874ef2983a9f04436cadbc34e12b4911}

\item 
\hypertarget{classSocketClient_a7bc13bcab467f2befa5f6dc182a82b71}{
void {\bfseries write\_\-to\_\-server} (\hyperlink{classXorpFd}{XorpFd} sock)}
\label{classSocketClient_a7bc13bcab467f2befa5f6dc182a82b71}

\item 
\hypertarget{classSocketClient_ab4d89158f79c4c011a66b18dc5cf0831}{
void {\bfseries send\_\-message\_\-complete} (AsyncFileWriter::Event e, const uint8\_\-t $\ast$buf, const size\_\-t buf\_\-bytes, const size\_\-t offset, \hyperlink{classSocketClient_aee21e26f27f4953a97a2c7dbcbc9c5dd}{SendCompleteCallback} cb)}
\label{classSocketClient_ab4d89158f79c4c011a66b18dc5cf0831}

\item 
\hypertarget{classSocketClient_abb5f0b9815919a36a98589fff88cd3e4}{
void {\bfseries async\_\-read\_\-start} (size\_\-t cnt=BGPPacket::COMMON\_\-HEADER\_\-LEN, size\_\-t ofset=0)}
\label{classSocketClient_abb5f0b9815919a36a98589fff88cd3e4}

\item 
\hypertarget{classSocketClient_a143cc41b2a84e8898f19b312f372db16}{
void {\bfseries async\_\-read\_\-message} (AsyncFileWriter::Event ev, const uint8\_\-t $\ast$buf, const size\_\-t buf\_\-bytes, const size\_\-t offset)}
\label{classSocketClient_a143cc41b2a84e8898f19b312f372db16}

\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classSocketClient_a2e40449f0a16b701d6d3e238906df45f}{
\hyperlink{classSocketClient_a928e364d34b6b010a810e6c7ab8054af}{MessageCallback} {\bfseries \_\-callback}}
\label{classSocketClient_a2e40449f0a16b701d6d3e238906df45f}

\item 
\hypertarget{classSocketClient_aeea8995a8ae47ca62fd0d69e6c828e3f}{
\hyperlink{classAsyncFileWriter}{AsyncFileWriter} $\ast$ {\bfseries \_\-async\_\-writer}}
\label{classSocketClient_aeea8995a8ae47ca62fd0d69e6c828e3f}

\item 
\hypertarget{classSocketClient_add280c0709d67a02303f7e37f4aee8ef}{
\hyperlink{classAsyncFileReader}{AsyncFileReader} $\ast$ {\bfseries \_\-async\_\-reader}}
\label{classSocketClient_add280c0709d67a02303f7e37f4aee8ef}

\item 
\hypertarget{classSocketClient_a92fc3a8a61c0f73206536d49ddb0f61d}{
bool {\bfseries \_\-disconnecting}}
\label{classSocketClient_a92fc3a8a61c0f73206536d49ddb0f61d}

\item 
\hypertarget{classSocketClient_ad11d8dd7df7f6cdefa6439802e91db9d}{
bool {\bfseries \_\-connecting}}
\label{classSocketClient_ad11d8dd7df7f6cdefa6439802e91db9d}

\item 
\hypertarget{classSocketClient_a6f6fb7b156bb2671e225f82fd45e8a63}{
bool {\bfseries \_\-md5sig}}
\label{classSocketClient_a6f6fb7b156bb2671e225f82fd45e8a63}

\item 
\hypertarget{classSocketClient_a2e9ec024b4466e1ee5bf9853906287d2}{
uint8\_\-t {\bfseries \_\-read\_\-buf} \mbox{[}BGPPacket::MAXPACKETSIZE\mbox{]}}
\label{classSocketClient_a2e9ec024b4466e1ee5bf9853906287d2}

\end{DoxyCompactItemize}


\subsection{Member Typedef Documentation}
\hypertarget{classSocketClient_a928e364d34b6b010a810e6c7ab8054af}{
\index{SocketClient@{SocketClient}!MessageCallback@{MessageCallback}}
\index{MessageCallback@{MessageCallback}!SocketClient@{SocketClient}}
\subsubsection[{MessageCallback}]{\setlength{\rightskip}{0pt plus 5cm}typedef XorpCallback4$<$bool,{\bf BGPPacket::Status},const uint8\_\-t$\ast$,size\_\-t, {\bf SocketClient}$\ast$$>$::RefPtr {\bf SocketClient::MessageCallback}}}
\label{classSocketClient_a928e364d34b6b010a810e6c7ab8054af}


Callback for incoming data. 


\begin{DoxyParams}{Parameters}
{\em const} & uint8\_\-t$\ast$ pointer to data. \\
\hline
{\em size\_\-t} & length of data. \\
\hline
\end{DoxyParams}
\hypertarget{classSocketClient_aee21e26f27f4953a97a2c7dbcbc9c5dd}{
\index{SocketClient@{SocketClient}!SendCompleteCallback@{SendCompleteCallback}}
\index{SendCompleteCallback@{SendCompleteCallback}!SocketClient@{SocketClient}}
\subsubsection[{SendCompleteCallback}]{\setlength{\rightskip}{0pt plus 5cm}typedef XorpCallback2$<$void,Event,const uint8\_\-t$\ast$$>$::RefPtr {\bf SocketClient::SendCompleteCallback}}}
\label{classSocketClient_aee21e26f27f4953a97a2c7dbcbc9c5dd}


Callback for data transmission. 


\begin{DoxyParams}{Parameters}
{\em Event} & status of \hyperlink{protocolthe-p}{the} send. \\
\hline
{\em const} & uint8\_\-t$\ast$ pointer to \hyperlink{protocolthe-p}{the} transmitted data. Allows caller to free \hyperlink{protocolthe-p}{the} data. \\
\hline
\end{DoxyParams}


\subsection{Constructor \& Destructor Documentation}
\hypertarget{classSocketClient_ac0f25d386dde4beb367d9be36e8807f3}{
\index{SocketClient@{SocketClient}!SocketClient@{SocketClient}}
\index{SocketClient@{SocketClient}!SocketClient@{SocketClient}}
\subsubsection[{SocketClient}]{\setlength{\rightskip}{0pt plus 5cm}SocketClient::SocketClient (
\begin{DoxyParamCaption}
\item[{const {\bf Iptuple} \&}]{iptuple, }
\item[{{\bf EventLoop} \&}]{e, }
\item[{bool}]{md5sig = {\ttfamily false}}
\end{DoxyParamCaption}
)}}
\label{classSocketClient_ac0f25d386dde4beb367d9be36e8807f3}

\begin{DoxyParams}{Parameters}
{\em iptuple} & specification of \hyperlink{protocolthe-p}{the} connection endpoints. \\
\hline
\end{DoxyParams}


\subsection{Member Function Documentation}
\hypertarget{classSocketClient_a98e6deea5575e90bd1016039e4e2e93d}{
\index{SocketClient@{SocketClient}!connect@{connect}}
\index{connect@{connect}!SocketClient@{SocketClient}}
\subsubsection[{connect}]{\setlength{\rightskip}{0pt plus 5cm}void SocketClient::connect (
\begin{DoxyParamCaption}
\item[{{\bf ConnectCallback}}]{cb}
\end{DoxyParamCaption}
)}}
\label{classSocketClient_a98e6deea5575e90bd1016039e4e2e93d}


Asynchronously connect. 


\begin{DoxyParams}{Parameters}
{\em cb} & is called when connection suceeds or fails. \\
\hline
\end{DoxyParams}
\hypertarget{classSocketClient_a1ebc6316eb6b4b912e7e67ebc025853a}{
\index{SocketClient@{SocketClient}!connect\_\-break@{connect\_\-break}}
\index{connect\_\-break@{connect\_\-break}!SocketClient@{SocketClient}}
\subsubsection[{connect\_\-break}]{\setlength{\rightskip}{0pt plus 5cm}void SocketClient::connect\_\-break (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{classSocketClient_a1ebc6316eb6b4b912e7e67ebc025853a}


Break asynchronous connect attempt. 

Each instance of \hyperlink{protocolthe-p}{the} this class has a single connection associated with it. If while we are attemping to connect to a peer (using \hyperlink{classSocketClient_a98e6deea5575e90bd1016039e4e2e93d}{connect()}), \hyperlink{protocolthe-p}{the} peer connects to us. It is necessary to stop \hyperlink{protocolthe-p}{the} outgoing connect. \hypertarget{classSocketClient_af30125c7ab70276b5c576214b108a045}{
\index{SocketClient@{SocketClient}!connected@{connected}}
\index{connected@{connected}!SocketClient@{SocketClient}}
\subsubsection[{connected}]{\setlength{\rightskip}{0pt plus 5cm}void SocketClient::connected (
\begin{DoxyParamCaption}
\item[{{\bf XorpFd}}]{s}
\end{DoxyParamCaption}
)}}
\label{classSocketClient_af30125c7ab70276b5c576214b108a045}


The peer has initiated \hyperlink{protocolthe-p}{the} connection so form an association. 


\begin{DoxyParams}{Parameters}
{\em s} & incoming socket file descriptor \\
\hline
\end{DoxyParams}
\hypertarget{classSocketClient_a13ec024c8c25391a9749608316021544}{
\index{SocketClient@{SocketClient}!disconnecting@{disconnecting}}
\index{disconnecting@{disconnecting}!SocketClient@{SocketClient}}
\subsubsection[{disconnecting}]{\setlength{\rightskip}{0pt plus 5cm}bool SocketClient::disconnecting (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classSocketClient_a13ec024c8c25391a9749608316021544}
\begin{DoxyReturn}{Returns}
Are we currrent disconecting. 
\end{DoxyReturn}
\hypertarget{classSocketClient_a4b1251cb08b51b1239a2b8796aba5b4a}{
\index{SocketClient@{SocketClient}!is\_\-connected@{is\_\-connected}}
\index{is\_\-connected@{is\_\-connected}!SocketClient@{SocketClient}}
\subsubsection[{is\_\-connected}]{\setlength{\rightskip}{0pt plus 5cm}bool SocketClient::is\_\-connected (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{classSocketClient_a4b1251cb08b51b1239a2b8796aba5b4a}
\begin{DoxyReturn}{Returns}
true if a session exists. 
\end{DoxyReturn}
\hypertarget{classSocketClient_adda9f83279c46819a6c58db894cbb809}{
\index{SocketClient@{SocketClient}!output\_\-queue\_\-busy@{output\_\-queue\_\-busy}}
\index{output\_\-queue\_\-busy@{output\_\-queue\_\-busy}!SocketClient@{SocketClient}}
\subsubsection[{output\_\-queue\_\-busy}]{\setlength{\rightskip}{0pt plus 5cm}bool SocketClient::output\_\-queue\_\-busy (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const}}
\label{classSocketClient_adda9f83279c46819a6c58db894cbb809}


Flow control signal. 

Data will be queued for transmission until a resource such as memory is exceeded. A correctly written client should stop sending messages if \hyperlink{protocolthe-p}{the} output queue is not draining.

\begin{DoxyReturn}{Returns}
true if its time to stop sending messages. 
\end{DoxyReturn}
\hypertarget{classSocketClient_a5a7f1f592bf355a900e838dbd1952112}{
\index{SocketClient@{SocketClient}!output\_\-queue\_\-size@{output\_\-queue\_\-size}}
\index{output\_\-queue\_\-size@{output\_\-queue\_\-size}!SocketClient@{SocketClient}}
\subsubsection[{output\_\-queue\_\-size}]{\setlength{\rightskip}{0pt plus 5cm}int SocketClient::output\_\-queue\_\-size (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const}}
\label{classSocketClient_a5a7f1f592bf355a900e838dbd1952112}
\begin{DoxyReturn}{Returns}
number of messages in \hyperlink{protocolthe-p}{the} output queue. 
\end{DoxyReturn}
\hypertarget{classSocketClient_a9639a4654eddb497beb9f6bc5fa4917c}{
\index{SocketClient@{SocketClient}!send\_\-message@{send\_\-message}}
\index{send\_\-message@{send\_\-message}!SocketClient@{SocketClient}}
\subsubsection[{send\_\-message}]{\setlength{\rightskip}{0pt plus 5cm}bool SocketClient::send\_\-message (
\begin{DoxyParamCaption}
\item[{const uint8\_\-t $\ast$}]{buf, }
\item[{size\_\-t}]{cnt, }
\item[{{\bf SendCompleteCallback}}]{cb}
\end{DoxyParamCaption}
)}}
\label{classSocketClient_a9639a4654eddb497beb9f6bc5fa4917c}


Asynchronously \hyperlink{structSend}{Send} a message. 


\begin{DoxyParams}{Parameters}
{\em buf} & pointer to data buffer. \\
\hline
{\em cnt} & length of data buffer. \\
\hline
{\em cb} & notification of success or failure.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if \hyperlink{protocolthe-p}{the} message is accepted. 
\end{DoxyReturn}
\hypertarget{classSocketClient_a92a500fff1dcaabf20f49209d79341ac}{
\index{SocketClient@{SocketClient}!still\_\-reading@{still\_\-reading}}
\index{still\_\-reading@{still\_\-reading}!SocketClient@{SocketClient}}
\subsubsection[{still\_\-reading}]{\setlength{\rightskip}{0pt plus 5cm}bool SocketClient::still\_\-reading (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{classSocketClient_a92a500fff1dcaabf20f49209d79341ac}
\begin{DoxyReturn}{Returns}
true if we are still reading. 
\end{DoxyReturn}


The documentation for this class was generated from the following files:\begin{DoxyCompactItemize}
\item 
/home/greearb/git/xorp.ct.github/xorp/bgp/socket.hh\item 
/home/greearb/git/xorp.ct.github/xorp/bgp/socket.cc\end{DoxyCompactItemize}
