1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
\section{Socket Class Reference}
\label{classSocket}\index{Socket@{Socket}}
{\tt \#include $<$Practical\-Socket.h$>$}
Inheritance diagram for Socket::\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=4cm]{classSocket}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item
{\bf $\sim$Socket} ()
\item
string {\bf get\-Local\-Address} () throw (Socket\-Exception)
\item
unsigned short {\bf get\-Local\-Port} () throw (Socket\-Exception)
\item
void {\bf set\-Local\-Port} (unsigned short local\-Port) throw (Socket\-Exception)
\item
void {\bf set\-Local\-Address\-And\-Port} (const string \&local\-Address, unsigned short local\-Port=0) throw (Socket\-Exception)
\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item
static void {\bf clean\-Up} () throw (Socket\-Exception)
\item
static unsigned short {\bf resolve\-Service} (const string \&service, const string \&protocol=\char`\"{}tcp\char`\"{})
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item
{\bf Socket} (int type, int protocol) throw (Socket\-Exception)
\item
{\bf Socket} (int {\bf sock\-Desc})
\end{CompactItemize}
\subsection*{Protected Attributes}
\begin{CompactItemize}
\item
int {\bf sock\-Desc}
\end{CompactItemize}
\subsection*{Private Member Functions}
\begin{CompactItemize}
\item
{\bf Socket} (const {\bf Socket} \&sock)
\item
void {\bf operator=} (const {\bf Socket} \&sock)
\end{CompactItemize}
\subsection{Detailed Description}
Base class representing basic communication endpoint
\subsection{Constructor \& Destructor Documentation}
\index{Socket@{Socket}!~Socket@{$\sim$Socket}}
\index{~Socket@{$\sim$Socket}!Socket@{Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Socket::$\sim$Socket ()}\label{classSocket_eac4eb6379a543d38ed88977d3b6630a}
Close and deallocate this socket \index{Socket@{Socket}!Socket@{Socket}}
\index{Socket@{Socket}!Socket@{Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Socket::Socket (const {\bf Socket} \& {\em sock})\hspace{0.3cm}{\tt [private]}}\label{classSocket_656389d58fa00729ff70c4e159623f5c}
\index{Socket@{Socket}!Socket@{Socket}}
\index{Socket@{Socket}!Socket@{Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Socket::Socket (int {\em type}, int {\em protocol}) throw ({\bf Socket\-Exception})\hspace{0.3cm}{\tt [protected]}}\label{classSocket_53e00027bab2125a2b407914c6148589}
\index{Socket@{Socket}!Socket@{Socket}}
\index{Socket@{Socket}!Socket@{Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Socket::Socket (int {\em sock\-Desc})\hspace{0.3cm}{\tt [protected]}}\label{classSocket_6a2609eef6559336a595a336f138d395}
\subsection{Member Function Documentation}
\index{Socket@{Socket}!getLocalAddress@{getLocalAddress}}
\index{getLocalAddress@{getLocalAddress}!Socket@{Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}string Socket::get\-Local\-Address () throw ({\bf Socket\-Exception})}\label{classSocket_0fca07bdfa97874fba1a17995ed7cda3}
Get the local address \begin{Desc}
\item[Returns:]local address of socket \end{Desc}
\begin{Desc}
\item[Exceptions:]
\begin{description}
\item[{\em \doxyref{Socket\-Exception}{p.}{classSocketException}}]thrown if fetch fails \end{description}
\end{Desc}
\index{Socket@{Socket}!getLocalPort@{getLocalPort}}
\index{getLocalPort@{getLocalPort}!Socket@{Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned short Socket::get\-Local\-Port () throw ({\bf Socket\-Exception})}\label{classSocket_e01143b667d69483a2f53d0f4ce7eeed}
Get the local port \begin{Desc}
\item[Returns:]local port of socket \end{Desc}
\begin{Desc}
\item[Exceptions:]
\begin{description}
\item[{\em \doxyref{Socket\-Exception}{p.}{classSocketException}}]thrown if fetch fails \end{description}
\end{Desc}
\index{Socket@{Socket}!setLocalPort@{setLocalPort}}
\index{setLocalPort@{setLocalPort}!Socket@{Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Socket::set\-Local\-Port (unsigned short {\em local\-Port}) throw ({\bf Socket\-Exception})}\label{classSocket_773fe4a35146002de76952e16fdebcfa}
Set the local port to the specified port and the local address to any interface \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em local\-Port}]local port \end{description}
\end{Desc}
\begin{Desc}
\item[Exceptions:]
\begin{description}
\item[{\em \doxyref{Socket\-Exception}{p.}{classSocketException}}]thrown if setting local port fails \end{description}
\end{Desc}
\index{Socket@{Socket}!setLocalAddressAndPort@{setLocalAddressAndPort}}
\index{setLocalAddressAndPort@{setLocalAddressAndPort}!Socket@{Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Socket::set\-Local\-Address\-And\-Port (const string \& {\em local\-Address}, unsigned short {\em local\-Port} = {\tt 0}) throw ({\bf Socket\-Exception})}\label{classSocket_a6b986410bc2e606ba27d01fa7cb8836}
Set the local port to the specified port and the local address to the specified address. If you omit the port, a random port will be selected. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em local\-Address}]local address \item[{\em local\-Port}]local port \end{description}
\end{Desc}
\begin{Desc}
\item[Exceptions:]
\begin{description}
\item[{\em \doxyref{Socket\-Exception}{p.}{classSocketException}}]thrown if setting local port or address fails \end{description}
\end{Desc}
\index{Socket@{Socket}!cleanUp@{cleanUp}}
\index{cleanUp@{cleanUp}!Socket@{Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Socket::clean\-Up () throw ({\bf Socket\-Exception})\hspace{0.3cm}{\tt [static]}}\label{classSocket_c5060aeb501044044351d5a85b3fc95f}
If Win\-Sock, unload the Win\-Sock DLLs; otherwise do nothing. We ignore this in our sample client code but include it in the library for completeness. If you are running on Windows and you are concerned about DLL resource consumption, call this after you are done with all \doxyref{Socket}{p.}{classSocket} instances. If you execute this on Windows while some instance of \doxyref{Socket}{p.}{classSocket} exists, you are toast. For portability of client code, this is an empty function on non-Windows platforms so you can always include it. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buffer}]buffer to receive the data \item[{\em buffer\-Len}]maximum number of bytes to read into buffer \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]number of bytes read, 0 for EOF, and -1 for error \end{Desc}
\begin{Desc}
\item[Exceptions:]
\begin{description}
\item[{\em \doxyref{Socket\-Exception}{p.}{classSocketException}}]thrown Win\-Sock clean up fails \end{description}
\end{Desc}
\index{Socket@{Socket}!resolveService@{resolveService}}
\index{resolveService@{resolveService}!Socket@{Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned short Socket::resolve\-Service (const string \& {\em service}, const string \& {\em protocol} = {\tt \char`\"{}tcp\char`\"{}})\hspace{0.3cm}{\tt [static]}}\label{classSocket_982c63b25c5b756321a74074a275adbc}
Resolve the specified service for the specified protocol to the corresponding port number in host byte order \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em service}]service to resolve (e.g., \char`\"{}http\char`\"{}) \item[{\em protocol}]protocol of service to resolve. Default is \char`\"{}tcp\char`\"{}. \end{description}
\end{Desc}
\index{Socket@{Socket}!operator=@{operator=}}
\index{operator=@{operator=}!Socket@{Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Socket::operator= (const {\bf Socket} \& {\em sock})\hspace{0.3cm}{\tt [private]}}\label{classSocket_1ef8f4c222c32756c8b1537323702df8}
\subsection{Member Data Documentation}
\index{Socket@{Socket}!sockDesc@{sockDesc}}
\index{sockDesc@{sockDesc}!Socket@{Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int {\bf Socket::sock\-Desc}\hspace{0.3cm}{\tt [protected]}}\label{classSocket_d5704d2fdfb062139e1f88831617bbfb}
The documentation for this class was generated from the following files:\begin{CompactItemize}
\item
{\bf Practical\-Socket.h}\item
{\bf Practical\-Socket.cpp}\end{CompactItemize}
|