summaryrefslogtreecommitdiff
path: root/doc/html/classCommunicatingSocket.html
blob: 614d31472ec286a8be9b914069889aee6bda7beb (plain) (blame)
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>anytun: CommunicatingSocket Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.1 -->
<div class="tabs">
  <ul>
    <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
    <li id="current"><a href="annotated.html"><span>Classes</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
    <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
    <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
  </ul></div>
<h1>CommunicatingSocket Class Reference</h1><!-- doxytag: class="CommunicatingSocket" --><!-- doxytag: inherits="Socket" --><code>#include &lt;<a class="el" href="PracticalSocket_8h-source.html">PracticalSocket.h</a>&gt;</code>
<p>
<p>Inheritance diagram for CommunicatingSocket:
<p><center><img src="classCommunicatingSocket.png" usemap="#CommunicatingSocket_map" border="0" alt=""></center>
<map name="CommunicatingSocket_map">
<area href="classSocket.html" alt="Socket" shape="rect" coords="72,0,207,24">
<area href="classTCPSocket.html" alt="TCPSocket" shape="rect" coords="0,112,135,136">
<area href="classUDPSocket.html" alt="UDPSocket" shape="rect" coords="145,112,280,136">
<area href="classUDPPacketSource.html" alt="UDPPacketSource" shape="rect" coords="145,168,280,192">
</map>
<a href="classCommunicatingSocket-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCommunicatingSocket.html#9192374d9baab8e189860aa8d913683c">connect</a> (const string &amp;foreignAddress, unsigned short foreignPort)  throw (SocketException)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCommunicatingSocket.html#ca4e86085c064641e86ae24ea29bbb94">send</a> (const void *buffer, int bufferLen)  throw (SocketException)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCommunicatingSocket.html#7cf1fd470c0060171b68df9f68c7bd01">recv</a> (void *buffer, int bufferLen)  throw (SocketException)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">string&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCommunicatingSocket.html#13f9eca30ef56836cf23c163c848c09e">getForeignAddress</a> ()  throw (SocketException)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned short&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCommunicatingSocket.html#184fbb4775184b87ebd886a5587eb1a3">getForeignPort</a> ()  throw (SocketException)</td></tr>

<tr><td colspan="2"><br><h2>Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCommunicatingSocket.html#0017517b8d6e761fde0c40475af3b2ab">CommunicatingSocket</a> (int type, int protocol)  throw (SocketException)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCommunicatingSocket.html#27d758db782b3be7d28741e92cb613d1">CommunicatingSocket</a> (int newConnSD)</td></tr>

</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
<a class="el" href="classSocket.html">Socket</a> which is able to connect, send, and receive 
<p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="0017517b8d6e761fde0c40475af3b2ab"></a><!-- doxytag: member="CommunicatingSocket::CommunicatingSocket" ref="0017517b8d6e761fde0c40475af3b2ab" args="(int type, int protocol)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">CommunicatingSocket::CommunicatingSocket           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>type</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>protocol</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%">  throw (<a class="el" href="classSocketException.html">SocketException</a>)<code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>

</div>
</div><p>
<a class="anchor" name="27d758db782b3be7d28741e92cb613d1"></a><!-- doxytag: member="CommunicatingSocket::CommunicatingSocket" ref="27d758db782b3be7d28741e92cb613d1" args="(int newConnSD)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">CommunicatingSocket::CommunicatingSocket           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>newConnSD</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="9192374d9baab8e189860aa8d913683c"></a><!-- doxytag: member="CommunicatingSocket::connect" ref="9192374d9baab8e189860aa8d913683c" args="(const string &amp;foreignAddress, unsigned short foreignPort)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void CommunicatingSocket::connect           </td>
          <td>(</td>
          <td class="paramtype">const string &amp;&nbsp;</td>
          <td class="paramname"> <em>foreignAddress</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned short&nbsp;</td>
          <td class="paramname"> <em>foreignPort</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%">  throw (<a class="el" href="classSocketException.html">SocketException</a>)</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Establish a socket connection with the given foreign address and port <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>foreignAddress</em>&nbsp;</td><td>foreign address (IP address or name) </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>foreignPort</em>&nbsp;</td><td>foreign port </td></tr>
  </table>
</dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em><a class="el" href="classSocketException.html">SocketException</a></em>&nbsp;</td><td>thrown if unable to establish connection </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="ca4e86085c064641e86ae24ea29bbb94"></a><!-- doxytag: member="CommunicatingSocket::send" ref="ca4e86085c064641e86ae24ea29bbb94" args="(const void *buffer, int bufferLen)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void CommunicatingSocket::send           </td>
          <td>(</td>
          <td class="paramtype">const void *&nbsp;</td>
          <td class="paramname"> <em>buffer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>bufferLen</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%">  throw (<a class="el" href="classSocketException.html">SocketException</a>)</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Write the given buffer to this socket. Call <a class="el" href="classCommunicatingSocket.html#9192374d9baab8e189860aa8d913683c">connect()</a> before calling <a class="el" href="classCommunicatingSocket.html#ca4e86085c064641e86ae24ea29bbb94">send()</a> <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>buffer</em>&nbsp;</td><td>buffer to be written </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>bufferLen</em>&nbsp;</td><td>number of bytes from buffer to be written </td></tr>
  </table>
</dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em><a class="el" href="classSocketException.html">SocketException</a></em>&nbsp;</td><td>thrown if unable to send data </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="7cf1fd470c0060171b68df9f68c7bd01"></a><!-- doxytag: member="CommunicatingSocket::recv" ref="7cf1fd470c0060171b68df9f68c7bd01" args="(void *buffer, int bufferLen)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int CommunicatingSocket::recv           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>buffer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>bufferLen</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%">  throw (<a class="el" href="classSocketException.html">SocketException</a>)</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Read into the given buffer up to bufferLen bytes data from this socket. Call <a class="el" href="classCommunicatingSocket.html#9192374d9baab8e189860aa8d913683c">connect()</a> before calling <a class="el" href="classCommunicatingSocket.html#7cf1fd470c0060171b68df9f68c7bd01">recv()</a> <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>buffer</em>&nbsp;</td><td>buffer to receive the data </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>bufferLen</em>&nbsp;</td><td>maximum number of bytes to read into buffer </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>number of bytes read, 0 for EOF, and -1 for error </dd></dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em><a class="el" href="classSocketException.html">SocketException</a></em>&nbsp;</td><td>thrown if unable to receive data </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="13f9eca30ef56836cf23c163c848c09e"></a><!-- doxytag: member="CommunicatingSocket::getForeignAddress" ref="13f9eca30ef56836cf23c163c848c09e" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">string CommunicatingSocket::getForeignAddress           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%">  throw (<a class="el" href="classSocketException.html">SocketException</a>)</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the foreign address. Call <a class="el" href="classCommunicatingSocket.html#9192374d9baab8e189860aa8d913683c">connect()</a> before calling <a class="el" href="classCommunicatingSocket.html#7cf1fd470c0060171b68df9f68c7bd01">recv()</a> <dl class="return" compact><dt><b>Returns:</b></dt><dd>foreign address </dd></dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em><a class="el" href="classSocketException.html">SocketException</a></em>&nbsp;</td><td>thrown if unable to fetch foreign address </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="184fbb4775184b87ebd886a5587eb1a3"></a><!-- doxytag: member="CommunicatingSocket::getForeignPort" ref="184fbb4775184b87ebd886a5587eb1a3" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned short CommunicatingSocket::getForeignPort           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%">  throw (<a class="el" href="classSocketException.html">SocketException</a>)</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the foreign port. Call <a class="el" href="classCommunicatingSocket.html#9192374d9baab8e189860aa8d913683c">connect()</a> before calling <a class="el" href="classCommunicatingSocket.html#7cf1fd470c0060171b68df9f68c7bd01">recv()</a> <dl class="return" compact><dt><b>Returns:</b></dt><dd>foreign port </dd></dl>
<dl compact><dt><b>Exceptions:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em><a class="el" href="classSocketException.html">SocketException</a></em>&nbsp;</td><td>thrown if unable to fetch foreign port </td></tr>
  </table>
</dl>

</div>
</div><p>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="PracticalSocket_8h-source.html">PracticalSocket.h</a><li><a class="el" href="PracticalSocket_8cpp.html">PracticalSocket.cpp</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Sun Oct 7 23:43:50 2007 for anytun by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.1 </small></address>
</body>
</html>