autodoc.git
/
traditional_manual
/
chapter_9.html
version
»
Context lines:
10
20
40
80
file
none
3
autodoc.git/traditional_manual/chapter_9.html:165:
<dd class='body--doc'><p><code>linger()</code>, <code>open()</code>, <code>open_socket()</code></p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>connect</b></span> </dt> <dd><p><code><code class='datatype'>bool</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>dest_addr</code>, <code class='datatype'>int</code> <code class='argument'>dest_port</code><b>)</b></code><br>
-
<code><code class='datatype'>bool</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>dest_addr</code>, <code class='datatype'>int</code> <code class='argument'>dest_port</code>, <code class='datatype'>string</code> <code class='argument'>src_addr</code>, <code class='datatype'>int</code> <code class='argument'>src_port</code><b>)</b></code></p></dd>
+
<code><code class='datatype'>bool</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>dest_addr</code>, <code class='datatype'>int</code> <code class='argument'>dest_port</code>, <code class='datatype'>string</code> <code class='argument'>src_addr</code>, <code class='datatype'>int</code> <code class='argument'>src_port</code><b>)</b></code><
br>
+
<code><code class='datatype'>string(8bit)<
/
code>|<code class='datatype'>int(0..0)</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>dest_addr</code>, <code class='datatype'>int</code> <code class='argument'>dest_port</code>, <code class='datatype'>string</code>|<code class='datatype'>int(0..0)</code> <code class='argument'>src_addr</code>, <code class='datatype'>int</code>|<code class='datatype'>int(0..0)</code> <code class='argument'>src_port</code>, <code class='datatype'>string(8bit)</code> <code class='argument'>data</code><b>)</b></code></
p></dd>
<dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Open a TCP/IP connection to the specified destination.</p> <p> In nonblocking mode, success is indicated with the write-callback, and failure with the close-callback or the read_oob-callback.</p>
-
+
<p> If the <code>data</code> argument is included the socket will use
+
TCP_FAST_OPEN if available, if not the data will <i>not be
+
sent</i>. In the data case the function either returns the data
+
that has not been sent (only one packet can be sent with this
+
option) or 0 if the connection failed immediately.</p>
</dd> <dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns <code class='expr'>1</code> on success, and <code class='expr'>0</code> on failure.</p>
+
<dd class='body--doc'><p>Returns <code class='expr'>1</code>
or the remaining <code class='expr'>data</code>
on success, and
+
<code class='expr'>0</code> on failure.</p>
</dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>In nonblocking mode <code class='expr'>0</code> (zero) may be returned and <code>errno()</code> set to <tt>EWOULDBLOCK</tt> or <tt>WSAEWOULDBLOCK</tt>. This should not be regarded as a connection failure.</p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>connect</b></span> </dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>host</code>, <code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>
void
</code>|<code class='datatype'>string</code> <code class='argument'>client</code>, <code class='datatype'>
void
</code>|<code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>client_port</code><b>)</b></code></p></dd>
+
<dd><p><code><code class='
modifier'>variant</code> <code class='
datatype'>int</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>host</code>, <code class='datatype'>int
(0..)
</code>|<code class='datatype'>string</code> <code class='argument'>port</code>
<b>)</b></code><br>
+
<code><code class='modifier'>variant</code> <code class='datatype'>int</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>host</code>
, <code class='datatype'>
int(0..)
</code>|<code class='datatype'>string</code> <code class='argument'>
port</code>, <code class='datatype'>string</code> <code class='argument'>
client</code>, <code class='datatype'>
int(0..)
</code>|<code class='datatype'>
string</code> <code class='argument'>client_port</code><b>)</b></code><br>
+
<code><code class='modifier'>variant</code> <code class='datatype'>string</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>host</code>, <code class='datatype'>
int
(0..)
</code>|<code class='datatype'>string</code> <code class='argument'>
port</code>, <code class='datatype'>int(0..0)</code>|<code class='datatype'>string</code> <code class='argument'>
client
</code>, <code class='datatype'>int(0..)</code>|<code class='datatype'>string</code> <code class='argument'>client
_port</code>
,
<
code class='datatype'>string</code> <code class='argument'>data</code><
b>)</b></code></p></dd>
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>
This
function connects
a
socket
previously
created
with
-
<
code
>
open_socket()
<
/code
>
to
a
remote
socket
through
TCP/IP
. The
-
<code>host</code> argument is the hostname or IP number of the remote machine.
-
A local IP and port can be explicitly bound by specifying <code>client</code>
-
and <code>client_port</code>.</p>
+
<dd class='body--doc'><p>
Open
a
TCP/IP
connection
to
the
specified
destination.
<
/p
>
+
<
p
>
In
nonblocking
mode,
success
is
indicated with the write-callback,
+
and failure with the close-callback or the read_oob-callback.<
/
p>
+
<p>
The <code>host</code> argument is the hostname or IP number of the remote
+
machine.
</p>
+
<p>
A local IP and port can be explicitly bound by specifying
+
<code>client</code> and <code>client_port</code>.</p>
+
<p> If the <code>data</code> argument is included the socket will use
+
TCP_FAST_OPEN if posible. In this mode the the function will
+
return the part of the data that has not been sent to the remote
+
server yet instead of 1 (you will have to use <code>write</code> to send
+
this data).</p>
+
<p> Note that TCP_FAST_OPEN requires server support, the connection
+
might fail even though the remote server exists. It might be
+
advicable to retry without TCP_FAST_OPEN (and remember this
+
fact)</p>
</dd> <dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>This function returns 1 for success, 0 otherwise.</p>
+
<dd class='body--doc'><p>This function returns 1
or the remaining <code>data</code>
for success, 0
+
otherwise.</p>
</dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>In nonblocking mode <code class='expr'>0</code> (zero) may be returned and
-
<code>errno()</code> set to <code class='expr'>EWOULDBLOCK</code> or
-
<code class='expr'>WSAEWOULDBLOCK</code>. This should not be regarded as a
+
<code>errno()</code> set to <code class='expr'>EWOULDBLOCK</code> or <code class='expr'>WSAEWOULDBLOCK</code>.
</p>
+
<p>
This should not be regarded as a
connection failure. In nonblocking mode you need to wait for a write or close callback before you know if the connection failed or not.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>query_address()</code>, <code>async_connect()</code>, <code>connect_unix()</code></p> </dd></dl> <hr />
autodoc.git/traditional_manual/chapter_9.html:2449:
<dd class='body--doc'><p>Opens a socket and binds it to port number on the local machine. If the second argument is present, the socket is set to nonblocking and the callback funcition is called whenever something connects to it. The callback will receive the id for this port as argument and should typically call <code>accept</code> to establish a connection.</p> <p> If the optional argument <code>ip</code> is given, <code>bind</code> will try to bind to an interface with that host name or IP number. Omitting this will bind to all available IPv4 addresses; specifying "::" will bind to all IPv4 and IPv6 addresses.</p>
+
<p> If the OS supports TCP_FASTOPEN it is enabled automatically.</p>
</dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>1 is returned on success, zero on failure. <code>errno</code> provides further details about the error in the latter case.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>accept</code>, <code>set_id</code></p> </dd></dl>