diff options
| author | Diego Nehab <diego.nehab@gmail.com> | 2015-08-25 15:43:48 -0300 |
|---|---|---|
| committer | Diego Nehab <diego.nehab@gmail.com> | 2015-08-25 15:43:48 -0300 |
| commit | 4110e4125dace9df3a744067066e5dee62670561 (patch) | |
| tree | 10927b57ea5c543054d01bd2bd538a4f97128678 /doc | |
| parent | 46d7e75f3e71d75bf07ae83d7df4aa276e484473 (diff) | |
| parent | 77bba625d7aaa0f9e118879163687fcbcb0b5a7b (diff) | |
| download | luasocket-4110e4125dace9df3a744067066e5dee62670561.tar.gz luasocket-4110e4125dace9df3a744067066e5dee62670561.tar.bz2 luasocket-4110e4125dace9df3a744067066e5dee62670561.zip | |
Merge branch 'agnostic'
Seems safe to move to master.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/reference.html | 2 | ||||
| -rw-r--r-- | doc/tcp.html | 199 | ||||
| -rw-r--r-- | doc/udp.html | 165 |
3 files changed, 220 insertions, 146 deletions
diff --git a/doc/reference.html b/doc/reference.html index e9bb5eb..6067ba6 100644 --- a/doc/reference.html +++ b/doc/reference.html | |||
| @@ -160,9 +160,11 @@ Support, Manual"> | |||
| 160 | <a href="socket.html#setsize">_SETSIZE</a>, | 160 | <a href="socket.html#setsize">_SETSIZE</a>, |
| 161 | <a href="socket.html#source">source</a>, | 161 | <a href="socket.html#source">source</a>, |
| 162 | <a href="tcp.html#socket.tcp">tcp</a>, | 162 | <a href="tcp.html#socket.tcp">tcp</a>, |
| 163 | <a href="tcp.html#socket.tcp4">tcp4</a>, | ||
| 163 | <a href="tcp.html#socket.tcp6">tcp6</a>, | 164 | <a href="tcp.html#socket.tcp6">tcp6</a>, |
| 164 | <a href="socket.html#try">try</a>, | 165 | <a href="socket.html#try">try</a>, |
| 165 | <a href="udp.html#socket.udp">udp</a>, | 166 | <a href="udp.html#socket.udp">udp</a>, |
| 167 | <a href="udp.html#socket.udp4">udp4</a>, | ||
| 166 | <a href="udp.html#socket.udp6">udp6</a>, | 168 | <a href="udp.html#socket.udp6">udp6</a>, |
| 167 | <a href="socket.html#version">_VERSION</a>. | 169 | <a href="socket.html#version">_VERSION</a>. |
| 168 | </blockquote> | 170 | </blockquote> |
diff --git a/doc/tcp.html b/doc/tcp.html index 4226d78..fb627a1 100644 --- a/doc/tcp.html +++ b/doc/tcp.html | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> | 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
| 3 | <html> | 3 | <html> |
| 4 | 4 | ||
| 5 | <head> | 5 | <head> |
| 6 | <meta name="description" content="LuaSocket: The TCP/IP support"> | 6 | <meta name="description" content="LuaSocket: The TCP/IP support"> |
| 7 | <meta name="keywords" content="Lua, LuaSocket, Socket, TCP, Library, Network, Support"> | 7 | <meta name="keywords" content="Lua, LuaSocket, Socket, TCP, Library, Network, Support"> |
| 8 | <title>LuaSocket: TCP/IP support</title> | 8 | <title>LuaSocket: TCP/IP support</title> |
| 9 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
| 10 | </head> | 10 | </head> |
| @@ -28,7 +28,7 @@ | |||
| 28 | <a href="index.html#download">download</a> · | 28 | <a href="index.html#download">download</a> · |
| 29 | <a href="installation.html">installation</a> · | 29 | <a href="installation.html">installation</a> · |
| 30 | <a href="introduction.html">introduction</a> · | 30 | <a href="introduction.html">introduction</a> · |
| 31 | <a href="reference.html">reference</a> | 31 | <a href="reference.html">reference</a> |
| 32 | </p> | 32 | </p> |
| 33 | </center> | 33 | </center> |
| 34 | <hr> | 34 | <hr> |
| @@ -36,21 +36,54 @@ | |||
| 36 | 36 | ||
| 37 | <!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 37 | <!-- tcp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 38 | 38 | ||
| 39 | <h2 id="tcp">TCP</h2> | 39 | <h2 id="tcp">TCP</h2> |
| 40 | 40 | ||
| 41 | <!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 41 | <!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 42 | 42 | ||
| 43 | <p class=name id="socket.tcp"> | 43 | <p class=name id="socket.tcp"> |
| 44 | socket.<b>tcp()</b> | 44 | socket.<b>tcp()</b> |
| 45 | </p> | 45 | </p> |
| 46 | 46 | ||
| 47 | <p class=description> | 47 | <p class=description> |
| 48 | Creates and returns an TCP master object. A master object can | ||
| 49 | be transformed into a server object with the method | ||
| 50 | <a href=#listen><tt>listen</tt></a> (after a call to <a | ||
| 51 | href=#bind><tt>bind</tt></a>) or into a client object with | ||
| 52 | the method <a href=#connect><tt>connect</tt></a>. The only other | ||
| 53 | method supported by a master object is the | ||
| 54 | <a href=#close><tt>close</tt></a> method.</p> | ||
| 55 | |||
| 56 | <p class=return> | ||
| 57 | In case of success, a new master object is returned. In case of error, | ||
| 58 | <b><tt>nil</tt></b> is returned, followed by an error message. | ||
| 59 | </p> | ||
| 60 | |||
| 61 | <p class=note> | ||
| 62 | Note: The choice between IPv4 and IPv6 happens during a call to | ||
| 63 | <a href=#bind><tt>bind</tt></a> or <a | ||
| 64 | href=#bind><tt>connect</tt></a>, depending on the address | ||
| 65 | family obtained from the resolver. | ||
| 66 | </p> | ||
| 67 | |||
| 68 | <p class=note> | ||
| 69 | Note: Before the choice between IPv4 and IPv6 happens, | ||
| 70 | the internal socket object is invalid and therefore <a | ||
| 71 | href=#setoption><tt>setoption</tt></a> will fail. | ||
| 72 | </p> | ||
| 73 | |||
| 74 | <!-- socket.tcp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 75 | |||
| 76 | <p class=name id="socket.tcp4"> | ||
| 77 | socket.<b>tcp4()</b> | ||
| 78 | </p> | ||
| 79 | |||
| 80 | <p class=description> | ||
| 48 | Creates and returns an IPv4 TCP master object. A master object can | 81 | Creates and returns an IPv4 TCP master object. A master object can |
| 49 | be transformed into a server object with the method | 82 | be transformed into a server object with the method |
| 50 | <a href=#listen><tt>listen</tt></a> (after a call to <a | 83 | <a href=#listen><tt>listen</tt></a> (after a call to <a |
| 51 | href=#bind><tt>bind</tt></a>) or into a client object with | 84 | href=#bind><tt>bind</tt></a>) or into a client object with |
| 52 | the method <a href=#connect><tt>connect</tt></a>. The only other | 85 | the method <a href=#connect><tt>connect</tt></a>. The only other |
| 53 | method supported by a master object is the | 86 | method supported by a master object is the |
| 54 | <a href=#close><tt>close</tt></a> method.</p> | 87 | <a href=#close><tt>close</tt></a> method.</p> |
| 55 | 88 | ||
| 56 | <p class=return> | 89 | <p class=return> |
| @@ -60,17 +93,17 @@ In case of success, a new master object is returned. In case of error, | |||
| 60 | 93 | ||
| 61 | <!-- socket.tcp6 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 94 | <!-- socket.tcp6 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 62 | 95 | ||
| 63 | <p class=name id="socket.tcp6"> | 96 | <p class=name id="socket.tcp6"> |
| 64 | socket.<b>tcp6()</b> | 97 | socket.<b>tcp6()</b> |
| 65 | </p> | 98 | </p> |
| 66 | 99 | ||
| 67 | <p class=description> | 100 | <p class=description> |
| 68 | Creates and returns an IPv6 TCP master object. A master object can | 101 | Creates and returns an IPv6 TCP master object. A master object can |
| 69 | be transformed into a server object with the method | 102 | be transformed into a server object with the method |
| 70 | <a href=#listen><tt>listen</tt></a> (after a call to <a | 103 | <a href=#listen><tt>listen</tt></a> (after a call to <a |
| 71 | href=#bind><tt>bind</tt></a>) or into a client object with | 104 | href=#bind><tt>bind</tt></a>) or into a client object with |
| 72 | the method <a href=#connect><tt>connect</tt></a>. The only other | 105 | the method <a href=#connect><tt>connect</tt></a>. The only other |
| 73 | method supported by a master object is the | 106 | method supported by a master object is the |
| 74 | <a href=#close><tt>close</tt></a> method.</p> | 107 | <a href=#close><tt>close</tt></a> method.</p> |
| 75 | 108 | ||
| 76 | <p class=return> | 109 | <p class=return> |
| @@ -85,7 +118,7 @@ Note: The TCP object returned will have the option | |||
| 85 | 118 | ||
| 86 | <!-- accept +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 119 | <!-- accept +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 87 | 120 | ||
| 88 | <p class=name id="accept"> | 121 | <p class=name id="accept"> |
| 89 | server:<b>accept()</b> | 122 | server:<b>accept()</b> |
| 90 | </p> | 123 | </p> |
| 91 | 124 | ||
| @@ -95,9 +128,9 @@ object and returns a client object representing that connection. | |||
| 95 | </p> | 128 | </p> |
| 96 | 129 | ||
| 97 | <p class=return> | 130 | <p class=return> |
| 98 | If a connection is successfully initiated, a client object is returned. | 131 | If a connection is successfully initiated, a client object is returned. |
| 99 | If a timeout condition is met, the method returns <b><tt>nil</tt></b> | 132 | If a timeout condition is met, the method returns <b><tt>nil</tt></b> |
| 100 | followed by the error string '<tt>timeout</tt>'. Other errors are | 133 | followed by the error string '<tt>timeout</tt>'. Other errors are |
| 101 | reported by <b><tt>nil</tt></b> followed by a message describing the error. | 134 | reported by <b><tt>nil</tt></b> followed by a message describing the error. |
| 102 | </p> | 135 | </p> |
| 103 | 136 | ||
| @@ -107,28 +140,28 @@ with a server object in | |||
| 107 | the <tt>recvt</tt> parameter before a call to <tt>accept</tt> does | 140 | the <tt>recvt</tt> parameter before a call to <tt>accept</tt> does |
| 108 | <em>not</em> guarantee <tt>accept</tt> will return immediately. Use the <a | 141 | <em>not</em> guarantee <tt>accept</tt> will return immediately. Use the <a |
| 109 | href=#settimeout><tt>settimeout</tt></a> method or <tt>accept</tt> | 142 | href=#settimeout><tt>settimeout</tt></a> method or <tt>accept</tt> |
| 110 | might block until <em>another</em> client shows up. | 143 | might block until <em>another</em> client shows up. |
| 111 | </p> | 144 | </p> |
| 112 | 145 | ||
| 113 | <!-- bind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 146 | <!-- bind +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 114 | 147 | ||
| 115 | <p class=name id="bind"> | 148 | <p class=name id="bind"> |
| 116 | master:<b>bind(</b>address, port<b>)</b> | 149 | master:<b>bind(</b>address, port<b>)</b> |
| 117 | </p> | 150 | </p> |
| 118 | 151 | ||
| 119 | <p class=description> | 152 | <p class=description> |
| 120 | Binds a master object to <tt>address</tt> and <tt>port</tt> on the | 153 | Binds a master object to <tt>address</tt> and <tt>port</tt> on the |
| 121 | local host. | 154 | local host. |
| 122 | 155 | ||
| 123 | <p class=parameters> | 156 | <p class=parameters> |
| 124 | <tt>Address</tt> can be an IP address or a host name. | 157 | <tt>Address</tt> can be an IP address or a host name. |
| 125 | <tt>Port</tt> must be an integer number in the range [0..64K). | 158 | <tt>Port</tt> must be an integer number in the range [0..64K). |
| 126 | If <tt>address</tt> | 159 | If <tt>address</tt> |
| 127 | is '<tt>*</tt>', the system binds to all local interfaces | 160 | is '<tt>*</tt>', the system binds to all local interfaces |
| 128 | using the <tt>INADDR_ANY</tt> constant or | 161 | using the <tt>INADDR_ANY</tt> constant or |
| 129 | <tt>IN6ADDR_ANY_INIT</tt>, according to the family. | 162 | <tt>IN6ADDR_ANY_INIT</tt>, according to the family. |
| 130 | If <tt>port</tt> is 0, the system automatically | 163 | If <tt>port</tt> is 0, the system automatically |
| 131 | chooses an ephemeral port. | 164 | chooses an ephemeral port. |
| 132 | </p> | 165 | </p> |
| 133 | 166 | ||
| 134 | <p class=return> | 167 | <p class=return> |
| @@ -137,13 +170,13 @@ method returns <b><tt>nil</tt></b> followed by an error message. | |||
| 137 | </p> | 170 | </p> |
| 138 | 171 | ||
| 139 | <p class=note> | 172 | <p class=note> |
| 140 | Note: The function <a href=socket.html#bind><tt>socket.bind</tt></a> | 173 | Note: The function <a href=socket.html#bind><tt>socket.bind</tt></a> |
| 141 | is available and is a shortcut for the creation of server sockets. | 174 | is available and is a shortcut for the creation of server sockets. |
| 142 | </p> | 175 | </p> |
| 143 | 176 | ||
| 144 | <!-- close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 177 | <!-- close ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 145 | 178 | ||
| 146 | <p class=name id="close"> | 179 | <p class=name id="close"> |
| 147 | master:<b>close()</b><br> | 180 | master:<b>close()</b><br> |
| 148 | client:<b>close()</b><br> | 181 | client:<b>close()</b><br> |
| 149 | server:<b>close()</b> | 182 | server:<b>close()</b> |
| @@ -154,14 +187,14 @@ Closes a TCP object. The internal socket used by the object is closed | |||
| 154 | and the local address to which the object was | 187 | and the local address to which the object was |
| 155 | bound is made available to other applications. No further operations | 188 | bound is made available to other applications. No further operations |
| 156 | (except for further calls to the <tt>close</tt> method) are allowed on | 189 | (except for further calls to the <tt>close</tt> method) are allowed on |
| 157 | a closed socket. | 190 | a closed socket. |
| 158 | </p> | 191 | </p> |
| 159 | 192 | ||
| 160 | <p class=note> | 193 | <p class=note> |
| 161 | Note: It is important to close all used sockets once they are not | 194 | Note: It is important to close all used sockets once they are not |
| 162 | needed, since, in many systems, each socket uses a file descriptor, | 195 | needed, since, in many systems, each socket uses a file descriptor, |
| 163 | which are limited system resources. Garbage-collected objects are | 196 | which are limited system resources. Garbage-collected objects are |
| 164 | automatically closed before destruction, though. | 197 | automatically closed before destruction, though. |
| 165 | </p> | 198 | </p> |
| 166 | 199 | ||
| 167 | <!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 200 | <!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| @@ -172,19 +205,19 @@ master:<b>connect(</b>address, port<b>)</b> | |||
| 172 | 205 | ||
| 173 | <p class=description> | 206 | <p class=description> |
| 174 | Attempts to connect a master object to a remote host, transforming it into a | 207 | Attempts to connect a master object to a remote host, transforming it into a |
| 175 | client object. | 208 | client object. |
| 176 | Client objects support methods | 209 | Client objects support methods |
| 177 | <a href=#send><tt>send</tt></a>, | 210 | <a href=#send><tt>send</tt></a>, |
| 178 | <a href=#receive><tt>receive</tt></a>, | 211 | <a href=#receive><tt>receive</tt></a>, |
| 179 | <a href=#getsockname><tt>getsockname</tt></a>, | 212 | <a href=#getsockname><tt>getsockname</tt></a>, |
| 180 | <a href=#getpeername><tt>getpeername</tt></a>, | 213 | <a href=#getpeername><tt>getpeername</tt></a>, |
| 181 | <a href=#settimeout><tt>settimeout</tt></a>, | 214 | <a href=#settimeout><tt>settimeout</tt></a>, |
| 182 | and <a href=#close><tt>close</tt></a>. | 215 | and <a href=#close><tt>close</tt></a>. |
| 183 | </p> | 216 | </p> |
| 184 | 217 | ||
| 185 | <p class=parameters> | 218 | <p class=parameters> |
| 186 | <tt>Address</tt> can be an IP address or a host name. | 219 | <tt>Address</tt> can be an IP address or a host name. |
| 187 | <tt>Port</tt> must be an integer number in the range [1..64K). | 220 | <tt>Port</tt> must be an integer number in the range [1..64K). |
| 188 | </p> | 221 | </p> |
| 189 | 222 | ||
| 190 | <p class=return> | 223 | <p class=return> |
| @@ -193,14 +226,14 @@ describing the error. In case of success, the method returns 1. | |||
| 193 | </p> | 226 | </p> |
| 194 | 227 | ||
| 195 | <p class=note> | 228 | <p class=note> |
| 196 | Note: The function <a href=socket.html#connect><tt>socket.connect</tt></a> | 229 | Note: The function <a href=socket.html#connect><tt>socket.connect</tt></a> |
| 197 | is available and is a shortcut for the creation of client sockets. | 230 | is available and is a shortcut for the creation of client sockets. |
| 198 | </p> | 231 | </p> |
| 199 | 232 | ||
| 200 | <p class=note> | 233 | <p class=note> |
| 201 | Note: Starting with LuaSocket 2.0, | 234 | Note: Starting with LuaSocket 2.0, |
| 202 | the <a href=#settimeout><tt>settimeout</tt></a> | 235 | the <a href=#settimeout><tt>settimeout</tt></a> |
| 203 | method affects the behavior of <tt>connect</tt>, causing it to return | 236 | method affects the behavior of <tt>connect</tt>, causing it to return |
| 204 | with an error in case of a timeout. If that happens, you can still call <a | 237 | with an error in case of a timeout. If that happens, you can still call <a |
| 205 | href=socket.html#select><tt>socket.select</tt></a> with the socket in the | 238 | href=socket.html#select><tt>socket.select</tt></a> with the socket in the |
| 206 | <tt>sendt</tt> table. The socket will be writable when the connection is | 239 | <tt>sendt</tt> table. The socket will be writable when the connection is |
| @@ -227,10 +260,10 @@ Returns information about the remote side of a connected client object. | |||
| 227 | </p> | 260 | </p> |
| 228 | 261 | ||
| 229 | <p class=return> | 262 | <p class=return> |
| 230 | Returns a string with the IP address of the peer, the | 263 | Returns a string with the IP address of the peer, the |
| 231 | port number that peer is using for the connection, | 264 | port number that peer is using for the connection, |
| 232 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). | 265 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). |
| 233 | In case of error, the method returns <b><tt>nil</tt></b>. | 266 | In case of error, the method returns <b><tt>nil</tt></b>. |
| 234 | </p> | 267 | </p> |
| 235 | 268 | ||
| 236 | <p class=note> | 269 | <p class=note> |
| @@ -246,13 +279,13 @@ server:<b>getsockname()</b> | |||
| 246 | </p> | 279 | </p> |
| 247 | 280 | ||
| 248 | <p class=description> | 281 | <p class=description> |
| 249 | Returns the local address information associated to the object. | 282 | Returns the local address information associated to the object. |
| 250 | </p> | 283 | </p> |
| 251 | 284 | ||
| 252 | <p class=return> | 285 | <p class=return> |
| 253 | The method returns a string with local IP address, a number with | 286 | The method returns a string with local IP address, a number with |
| 254 | the local port, | 287 | the local port, |
| 255 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). | 288 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). |
| 256 | In case of error, the method returns <b><tt>nil</tt></b>. | 289 | In case of error, the method returns <b><tt>nil</tt></b>. |
| 257 | </p> | 290 | </p> |
| 258 | 291 | ||
| @@ -266,32 +299,32 @@ server:<b>getstats()</b><br> | |||
| 266 | 299 | ||
| 267 | <p class=description> | 300 | <p class=description> |
| 268 | Returns accounting information on the socket, useful for throttling | 301 | Returns accounting information on the socket, useful for throttling |
| 269 | of bandwidth. | 302 | of bandwidth. |
| 270 | </p> | 303 | </p> |
| 271 | 304 | ||
| 272 | <p class=return> | 305 | <p class=return> |
| 273 | The method returns the number of bytes received, the number of bytes sent, | 306 | The method returns the number of bytes received, the number of bytes sent, |
| 274 | and the age of the socket object in seconds. | 307 | and the age of the socket object in seconds. |
| 275 | </p> | 308 | </p> |
| 276 | 309 | ||
| 277 | <!-- listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 310 | <!-- listen ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 278 | 311 | ||
| 279 | <p class=name id="listen"> | 312 | <p class=name id="listen"> |
| 280 | master:<b>listen(</b>backlog<b>)</b> | 313 | master:<b>listen(</b>backlog<b>)</b> |
| 281 | </p> | 314 | </p> |
| 282 | 315 | ||
| 283 | <p class=description> | 316 | <p class=description> |
| 284 | Specifies the socket is willing to receive connections, transforming the | 317 | Specifies the socket is willing to receive connections, transforming the |
| 285 | object into a server object. Server objects support the | 318 | object into a server object. Server objects support the |
| 286 | <a href=#accept><tt>accept</tt></a>, | 319 | <a href=#accept><tt>accept</tt></a>, |
| 287 | <a href=#getsockname><tt>getsockname</tt></a>, | 320 | <a href=#getsockname><tt>getsockname</tt></a>, |
| 288 | <a href=#setoption><tt>setoption</tt></a>, | 321 | <a href=#setoption><tt>setoption</tt></a>, |
| 289 | <a href=#settimeout><tt>settimeout</tt></a>, | 322 | <a href=#settimeout><tt>settimeout</tt></a>, |
| 290 | and <a href=#close><tt>close</tt></a> methods. | 323 | and <a href=#close><tt>close</tt></a> methods. |
| 291 | </p> | 324 | </p> |
| 292 | 325 | ||
| 293 | <p class=parameters> | 326 | <p class=parameters> |
| 294 | The parameter <tt>backlog</tt> specifies the number of client | 327 | The parameter <tt>backlog</tt> specifies the number of client |
| 295 | connections that can | 328 | connections that can |
| 296 | be queued waiting for service. If the queue is full and another client | 329 | be queued waiting for service. If the queue is full and another client |
| 297 | attempts connection, the connection is refused. | 330 | attempts connection, the connection is refused. |
| @@ -310,11 +343,11 @@ client:<b>receive(</b>[pattern [, prefix]]<b>)</b> | |||
| 310 | 343 | ||
| 311 | <p class=description> | 344 | <p class=description> |
| 312 | Reads data from a client object, according to the specified <em>read | 345 | Reads data from a client object, according to the specified <em>read |
| 313 | pattern</em>. Patterns follow the Lua file I/O format, and the difference in performance between all patterns is negligible. | 346 | pattern</em>. Patterns follow the Lua file I/O format, and the difference in performance between all patterns is negligible. |
| 314 | </p> | 347 | </p> |
| 315 | 348 | ||
| 316 | <p class=parameters> | 349 | <p class=parameters> |
| 317 | <tt>Pattern</tt> can be any of the following: | 350 | <tt>Pattern</tt> can be any of the following: |
| 318 | </p> | 351 | </p> |
| 319 | 352 | ||
| 320 | <ul> | 353 | <ul> |
| @@ -325,7 +358,7 @@ terminated by a LF character (ASCII 10), optionally preceded by a | |||
| 325 | CR character (ASCII 13). The CR and LF characters are not included in | 358 | CR character (ASCII 13). The CR and LF characters are not included in |
| 326 | the returned line. In fact, <em>all</em> CR characters are | 359 | the returned line. In fact, <em>all</em> CR characters are |
| 327 | ignored by the pattern. This is the default pattern; | 360 | ignored by the pattern. This is the default pattern; |
| 328 | <li> <tt>number</tt>: causes the method to read a specified <tt>number</tt> | 361 | <li> <tt>number</tt>: causes the method to read a specified <tt>number</tt> |
| 329 | of bytes from the socket. | 362 | of bytes from the socket. |
| 330 | </ul> | 363 | </ul> |
| 331 | 364 | ||
| @@ -347,10 +380,10 @@ closed before the transmission was completed or the string | |||
| 347 | <p class=note> | 380 | <p class=note> |
| 348 | <b>Important note</b>: This function was changed <em>severely</em>. It used | 381 | <b>Important note</b>: This function was changed <em>severely</em>. It used |
| 349 | to support multiple patterns (but I have never seen this feature used) and | 382 | to support multiple patterns (but I have never seen this feature used) and |
| 350 | now it doesn't anymore. Partial results used to be returned in the same | 383 | now it doesn't anymore. Partial results used to be returned in the same |
| 351 | way as successful results. This last feature violated the idea that all | 384 | way as successful results. This last feature violated the idea that all |
| 352 | functions should return <tt><b>nil</b></tt> on error. Thus it was changed | 385 | functions should return <tt><b>nil</b></tt> on error. Thus it was changed |
| 353 | too. | 386 | too. |
| 354 | </p> | 387 | </p> |
| 355 | 388 | ||
| 356 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 389 | <!-- send +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| @@ -366,7 +399,7 @@ Sends <tt>data</tt> through client object. | |||
| 366 | <p class=parameters> | 399 | <p class=parameters> |
| 367 | <tt>Data</tt> is the string to be sent. The optional arguments | 400 | <tt>Data</tt> is the string to be sent. The optional arguments |
| 368 | <tt>i</tt> and <tt>j</tt> work exactly like the standard | 401 | <tt>i</tt> and <tt>j</tt> work exactly like the standard |
| 369 | <tt>string.sub</tt> Lua function to allow the selection of a | 402 | <tt>string.sub</tt> Lua function to allow the selection of a |
| 370 | substring to be sent. | 403 | substring to be sent. |
| 371 | </p> | 404 | </p> |
| 372 | 405 | ||
| @@ -385,10 +418,10 @@ there was a timeout during the operation. | |||
| 385 | </p> | 418 | </p> |
| 386 | 419 | ||
| 387 | <p class=note> | 420 | <p class=note> |
| 388 | Note: Output is <em>not</em> buffered. For small strings, | 421 | Note: Output is <em>not</em> buffered. For small strings, |
| 389 | it is always better to concatenate them in Lua | 422 | it is always better to concatenate them in Lua |
| 390 | (with the '<tt>..</tt>' operator) and send the result in one call | 423 | (with the '<tt>..</tt>' operator) and send the result in one call |
| 391 | instead of calling the method several times. | 424 | instead of calling the method several times. |
| 392 | </p> | 425 | </p> |
| 393 | 426 | ||
| 394 | <!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 427 | <!-- setoption ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| @@ -400,12 +433,12 @@ server:<b>setoption(</b>option [, value]<b>)</b> | |||
| 400 | 433 | ||
| 401 | <p class=description> | 434 | <p class=description> |
| 402 | Sets options for the TCP object. Options are only needed by low-level or | 435 | Sets options for the TCP object. Options are only needed by low-level or |
| 403 | time-critical applications. You should only modify an option if you | 436 | time-critical applications. You should only modify an option if you |
| 404 | are sure you need it. | 437 | are sure you need it. |
| 405 | </p> | 438 | </p> |
| 406 | 439 | ||
| 407 | <p class=parameters> | 440 | <p class=parameters> |
| 408 | <tt>Option</tt> is a string with the option name, and <tt>value</tt> | 441 | <tt>Option</tt> is a string with the option name, and <tt>value</tt> |
| 409 | depends on the option being set: | 442 | depends on the option being set: |
| 410 | 443 | ||
| 411 | <ul> | 444 | <ul> |
| @@ -413,7 +446,7 @@ depends on the option being set: | |||
| 413 | <li> '<tt>keepalive</tt>': Setting this option to <tt>true</tt> enables | 446 | <li> '<tt>keepalive</tt>': Setting this option to <tt>true</tt> enables |
| 414 | the periodic transmission of messages on a connected socket. Should the | 447 | the periodic transmission of messages on a connected socket. Should the |
| 415 | connected party fail to respond to these messages, the connection is | 448 | connected party fail to respond to these messages, the connection is |
| 416 | considered broken and processes using the socket are notified; | 449 | considered broken and processes using the socket are notified; |
| 417 | 450 | ||
| 418 | <li> '<tt>linger</tt>': Controls the action taken when unsent data are | 451 | <li> '<tt>linger</tt>': Controls the action taken when unsent data are |
| 419 | queued on a socket and a close is performed. The value is a table with a | 452 | queued on a socket and a close is performed. The value is a table with a |
| @@ -424,13 +457,13 @@ it is able to transmit the data or until '<tt>timeout</tt>' has passed. If | |||
| 424 | '<tt>on</tt>' is <tt>false</tt> and a close is issued, the system will | 457 | '<tt>on</tt>' is <tt>false</tt> and a close is issued, the system will |
| 425 | process the close in a manner that allows the process to continue as | 458 | process the close in a manner that allows the process to continue as |
| 426 | quickly as possible. I do not advise you to set this to anything other than | 459 | quickly as possible. I do not advise you to set this to anything other than |
| 427 | zero; | 460 | zero; |
| 428 | 461 | ||
| 429 | <li> '<tt>reuseaddr</tt>': Setting this option indicates that the rules | 462 | <li> '<tt>reuseaddr</tt>': Setting this option indicates that the rules |
| 430 | used in validating addresses supplied in a call to | 463 | used in validating addresses supplied in a call to |
| 431 | <a href=#bind><tt>bind</tt></a> should allow reuse of local addresses; | 464 | <a href=#bind><tt>bind</tt></a> should allow reuse of local addresses; |
| 432 | 465 | ||
| 433 | <li> '<tt>tcp-nodelay</tt>': Setting this option to <tt>true</tt> | 466 | <li> '<tt>tcp-nodelay</tt>': Setting this option to <tt>true</tt> |
| 434 | disables the Nagle's algorithm for the connection; | 467 | disables the Nagle's algorithm for the connection; |
| 435 | 468 | ||
| 436 | <li> '<tt>ipv6-v6only</tt>': | 469 | <li> '<tt>ipv6-v6only</tt>': |
| @@ -485,7 +518,7 @@ server:<b>setstats(</b>received, sent, age<b>)</b><br> | |||
| 485 | 518 | ||
| 486 | <p class=description> | 519 | <p class=description> |
| 487 | Resets accounting information on the socket, useful for throttling | 520 | Resets accounting information on the socket, useful for throttling |
| 488 | of bandwidth. | 521 | of bandwidth. |
| 489 | </p> | 522 | </p> |
| 490 | 523 | ||
| 491 | <p class=parameters> | 524 | <p class=parameters> |
| @@ -495,7 +528,7 @@ of bandwidth. | |||
| 495 | </p> | 528 | </p> |
| 496 | 529 | ||
| 497 | <p class=return> | 530 | <p class=return> |
| 498 | The method returns 1 in case of success and <tt><b>nil</b></tt> otherwise. | 531 | The method returns 1 in case of success and <tt><b>nil</b></tt> otherwise. |
| 499 | </p> | 532 | </p> |
| 500 | 533 | ||
| 501 | <!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 534 | <!-- settimeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| @@ -509,8 +542,8 @@ server:<b>settimeout(</b>value [, mode]<b>)</b> | |||
| 509 | <p class=description> | 542 | <p class=description> |
| 510 | Changes the timeout values for the object. By default, | 543 | Changes the timeout values for the object. By default, |
| 511 | all I/O operations are blocking. That is, any call to the methods | 544 | all I/O operations are blocking. That is, any call to the methods |
| 512 | <a href=#send><tt>send</tt></a>, | 545 | <a href=#send><tt>send</tt></a>, |
| 513 | <a href=#receive><tt>receive</tt></a>, and | 546 | <a href=#receive><tt>receive</tt></a>, and |
| 514 | <a href=#accept><tt>accept</tt></a> | 547 | <a href=#accept><tt>accept</tt></a> |
| 515 | will block indefinitely, until the operation completes. The | 548 | will block indefinitely, until the operation completes. The |
| 516 | <tt>settimeout</tt> method defines a limit on the amount of time the | 549 | <tt>settimeout</tt> method defines a limit on the amount of time the |
| @@ -521,7 +554,7 @@ time has elapsed, the affected methods give up and fail with an error code. | |||
| 521 | <p class=parameters> | 554 | <p class=parameters> |
| 522 | The amount of time to wait is specified as the | 555 | The amount of time to wait is specified as the |
| 523 | <tt>value</tt> parameter, in seconds. There are two timeout modes and | 556 | <tt>value</tt> parameter, in seconds. There are two timeout modes and |
| 524 | both can be used together for fine tuning: | 557 | both can be used together for fine tuning: |
| 525 | </p> | 558 | </p> |
| 526 | 559 | ||
| 527 | <ul> | 560 | <ul> |
| @@ -532,7 +565,7 @@ default mode;</li> | |||
| 532 | 565 | ||
| 533 | <li> '<tt>t</tt>': <em>total</em> timeout. Specifies the upper limit on | 566 | <li> '<tt>t</tt>': <em>total</em> timeout. Specifies the upper limit on |
| 534 | the amount of time LuaSocket can block a Lua script before returning from | 567 | the amount of time LuaSocket can block a Lua script before returning from |
| 535 | a call.</li> | 568 | a call.</li> |
| 536 | </ul> | 569 | </ul> |
| 537 | 570 | ||
| 538 | <p class=parameters> | 571 | <p class=parameters> |
| @@ -562,7 +595,7 @@ client:<b>shutdown(</b>mode<b>)</b><br> | |||
| 562 | </p> | 595 | </p> |
| 563 | 596 | ||
| 564 | <p class=description> | 597 | <p class=description> |
| 565 | Shuts down part of a full-duplex connection. | 598 | Shuts down part of a full-duplex connection. |
| 566 | </p> | 599 | </p> |
| 567 | 600 | ||
| 568 | <p class=parameters> | 601 | <p class=parameters> |
| @@ -608,7 +641,7 @@ server:<b>getfd()</b> | |||
| 608 | </p> | 641 | </p> |
| 609 | 642 | ||
| 610 | <p class=description> | 643 | <p class=description> |
| 611 | Returns the underling socket descriptor or handle associated to the object. | 644 | Returns the underling socket descriptor or handle associated to the object. |
| 612 | </p> | 645 | </p> |
| 613 | 646 | ||
| 614 | <p class=return> | 647 | <p class=return> |
diff --git a/doc/udp.html b/doc/udp.html index e5b0ad0..a300f2f 100644 --- a/doc/udp.html +++ b/doc/udp.html | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | <head> | 5 | <head> |
| 6 | <meta name="description" content="LuaSocket: The UDP support"> | 6 | <meta name="description" content="LuaSocket: The UDP support"> |
| 7 | <meta name="keywords" content="Lua, LuaSocket, Socket, UDP, Library, Network, Support"> | 7 | <meta name="keywords" content="Lua, LuaSocket, Socket, UDP, Library, Network, Support"> |
| 8 | <title>LuaSocket: UDP support</title> | 8 | <title>LuaSocket: UDP support</title> |
| 9 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
| 10 | </head> | 10 | </head> |
| @@ -28,7 +28,7 @@ | |||
| 28 | <a href="index.html#download">download</a> · | 28 | <a href="index.html#download">download</a> · |
| 29 | <a href="installation.html">installation</a> · | 29 | <a href="installation.html">installation</a> · |
| 30 | <a href="introduction.html">introduction</a> · | 30 | <a href="introduction.html">introduction</a> · |
| 31 | <a href="reference.html">reference</a> | 31 | <a href="reference.html">reference</a> |
| 32 | </p> | 32 | </p> |
| 33 | </center> | 33 | </center> |
| 34 | <hr> | 34 | <hr> |
| @@ -37,7 +37,7 @@ | |||
| 37 | 37 | ||
| 38 | <!-- udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 38 | <!-- udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 39 | 39 | ||
| 40 | <h2 id="udp">UDP</h2> | 40 | <h2 id="udp">UDP</h2> |
| 41 | 41 | ||
| 42 | <!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 42 | <!-- socket.udp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 43 | 43 | ||
| @@ -46,19 +46,62 @@ socket.<b>udp()</b> | |||
| 46 | </p> | 46 | </p> |
| 47 | 47 | ||
| 48 | <p class="description"> | 48 | <p class="description"> |
| 49 | Creates and returns an unconnected IPv4 UDP object. | 49 | Creates and returns an unconnected UDP object. |
| 50 | Unconnected objects support the | 50 | Unconnected objects support the |
| 51 | <a href="#sendto"><tt>sendto</tt></a>, | 51 | <a href="#sendto"><tt>sendto</tt></a>, |
| 52 | <a href="#receive"><tt>receive</tt></a>, | 52 | <a href="#receive"><tt>receive</tt></a>, |
| 53 | <a href="#receivefrom"><tt>receivefrom</tt></a>, | 53 | <a href="#receivefrom"><tt>receivefrom</tt></a>, |
| 54 | <a href="#getoption"><tt>getoption</tt></a>, | 54 | <a href="#getoption"><tt>getoption</tt></a>, |
| 55 | <a href="#getsockname"><tt>getsockname</tt></a>, | 55 | <a href="#getsockname"><tt>getsockname</tt></a>, |
| 56 | <a href="#setoption"><tt>setoption</tt></a>, | 56 | <a href="#setoption"><tt>setoption</tt></a>, |
| 57 | <a href="#settimeout"><tt>settimeout</tt></a>, | 57 | <a href="#settimeout"><tt>settimeout</tt></a>, |
| 58 | <a href="#setpeername"><tt>setpeername</tt></a>, | 58 | <a href="#setpeername"><tt>setpeername</tt></a>, |
| 59 | <a href="#setsockname"><tt>setsockname</tt></a>, and | 59 | <a href="#setsockname"><tt>setsockname</tt></a>, and |
| 60 | <a href="#close"><tt>close</tt></a>. | 60 | <a href="#close"><tt>close</tt></a>. |
| 61 | The <a href="#setpeername"><tt>setpeername</tt></a> | 61 | The <a href="#setpeername"><tt>setpeername</tt></a> |
| 62 | is used to connect the object. | ||
| 63 | </p> | ||
| 64 | |||
| 65 | <p class="return"> | ||
| 66 | In case of success, a new unconnected UDP object | ||
| 67 | returned. In case of error, <b><tt>nil</tt></b> is returned, followed by | ||
| 68 | an error message. | ||
| 69 | </p> | ||
| 70 | |||
| 71 | <p class=note> | ||
| 72 | Note: The choice between IPv4 and IPv6 happens during a call to | ||
| 73 | <a href=#sendto><tt>sendto</tt></a>, <a | ||
| 74 | href=#setpeername><tt>setpeername</tt></a>, or <a | ||
| 75 | href=#setsockname><tt>sockname</tt></a>, depending on the address | ||
| 76 | family obtained from the resolver. | ||
| 77 | </p> | ||
| 78 | |||
| 79 | <p class=note> | ||
| 80 | Note: Before the choice between IPv4 and IPv6 happens, | ||
| 81 | the internal socket object is invalid and therefore <a | ||
| 82 | href=#setoption><tt>setoption</tt></a> will fail. | ||
| 83 | </p> | ||
| 84 | |||
| 85 | <!-- socket.udp4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 86 | |||
| 87 | <p class="name" id="socket.udp"> | ||
| 88 | socket.<b>udp4()</b> | ||
| 89 | </p> | ||
| 90 | |||
| 91 | <p class="description"> | ||
| 92 | Creates and returns an unconnected IPv4 UDP object. | ||
| 93 | Unconnected objects support the | ||
| 94 | <a href="#sendto"><tt>sendto</tt></a>, | ||
| 95 | <a href="#receive"><tt>receive</tt></a>, | ||
| 96 | <a href="#receivefrom"><tt>receivefrom</tt></a>, | ||
| 97 | <a href="#getoption"><tt>getoption</tt></a>, | ||
| 98 | <a href="#getsockname"><tt>getsockname</tt></a>, | ||
| 99 | <a href="#setoption"><tt>setoption</tt></a>, | ||
| 100 | <a href="#settimeout"><tt>settimeout</tt></a>, | ||
| 101 | <a href="#setpeername"><tt>setpeername</tt></a>, | ||
| 102 | <a href="#setsockname"><tt>setsockname</tt></a>, and | ||
| 103 | <a href="#close"><tt>close</tt></a>. | ||
| 104 | The <a href="#setpeername"><tt>setpeername</tt></a> | ||
| 62 | is used to connect the object. | 105 | is used to connect the object. |
| 63 | </p> | 106 | </p> |
| 64 | 107 | ||
| @@ -75,19 +118,19 @@ socket.<b>udp6()</b> | |||
| 75 | </p> | 118 | </p> |
| 76 | 119 | ||
| 77 | <p class="description"> | 120 | <p class="description"> |
| 78 | Creates and returns an unconnected IPv6 UDP object. | 121 | Creates and returns an unconnected IPv6 UDP object. |
| 79 | Unconnected objects support the | 122 | Unconnected objects support the |
| 80 | <a href="#sendto"><tt>sendto</tt></a>, | 123 | <a href="#sendto"><tt>sendto</tt></a>, |
| 81 | <a href="#receive"><tt>receive</tt></a>, | 124 | <a href="#receive"><tt>receive</tt></a>, |
| 82 | <a href="#receivefrom"><tt>receivefrom</tt></a>, | 125 | <a href="#receivefrom"><tt>receivefrom</tt></a>, |
| 83 | <a href="#getoption"><tt>getoption</tt></a>, | 126 | <a href="#getoption"><tt>getoption</tt></a>, |
| 84 | <a href="#getsockname"><tt>getsockname</tt></a>, | 127 | <a href="#getsockname"><tt>getsockname</tt></a>, |
| 85 | <a href="#setoption"><tt>setoption</tt></a>, | 128 | <a href="#setoption"><tt>setoption</tt></a>, |
| 86 | <a href="#settimeout"><tt>settimeout</tt></a>, | 129 | <a href="#settimeout"><tt>settimeout</tt></a>, |
| 87 | <a href="#setpeername"><tt>setpeername</tt></a>, | 130 | <a href="#setpeername"><tt>setpeername</tt></a>, |
| 88 | <a href="#setsockname"><tt>setsockname</tt></a>, and | 131 | <a href="#setsockname"><tt>setsockname</tt></a>, and |
| 89 | <a href="#close"><tt>close</tt></a>. | 132 | <a href="#close"><tt>close</tt></a>. |
| 90 | The <a href="#setpeername"><tt>setpeername</tt></a> | 133 | The <a href="#setpeername"><tt>setpeername</tt></a> |
| 91 | is used to connect the object. | 134 | is used to connect the object. |
| 92 | </p> | 135 | </p> |
| 93 | 136 | ||
| @@ -102,10 +145,6 @@ Note: The TCP object returned will have the option | |||
| 102 | "<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>. | 145 | "<tt>ipv6-v6only</tt>" set to <tt><b>true</b></tt>. |
| 103 | </p> | 146 | </p> |
| 104 | 147 | ||
| 105 | |||
| 106 | |||
| 107 | <!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 108 | |||
| 109 | <!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 148 | <!-- close +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 110 | 149 | ||
| 111 | <p class="name" id="close"> | 150 | <p class="name" id="close"> |
| @@ -142,10 +181,10 @@ associated with a connected UDP object. | |||
| 142 | 181 | ||
| 143 | 182 | ||
| 144 | <p class=return> | 183 | <p class=return> |
| 145 | Returns a string with the IP address of the peer, the | 184 | Returns a string with the IP address of the peer, the |
| 146 | port number that peer is using for the connection, | 185 | port number that peer is using for the connection, |
| 147 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). | 186 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). |
| 148 | In case of error, the method returns <b><tt>nil</tt></b>. | 187 | In case of error, the method returns <b><tt>nil</tt></b>. |
| 149 | </p> | 188 | </p> |
| 150 | 189 | ||
| 151 | <p class="note"> | 190 | <p class="note"> |
| @@ -165,9 +204,9 @@ Returns the local address information associated to the object. | |||
| 165 | 204 | ||
| 166 | 205 | ||
| 167 | <p class=return> | 206 | <p class=return> |
| 168 | The method returns a string with local IP address, a number with | 207 | The method returns a string with local IP address, a number with |
| 169 | the local port, | 208 | the local port, |
| 170 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). | 209 | and a string with the family ("<tt>inet</tt>" or "<tt>inet6</tt>"). |
| 171 | In case of error, the method returns <b><tt>nil</tt></b>. | 210 | In case of error, the method returns <b><tt>nil</tt></b>. |
| 172 | </p> | 211 | </p> |
| 173 | 212 | ||
| @@ -217,7 +256,7 @@ unconnected:<b>receivefrom(</b>[size]<b>)</b> | |||
| 217 | </p> | 256 | </p> |
| 218 | 257 | ||
| 219 | <p class="description"> | 258 | <p class="description"> |
| 220 | Works exactly as the <a href="#receive"><tt>receive</tt></a> | 259 | Works exactly as the <a href="#receive"><tt>receive</tt></a> |
| 221 | method, except it returns the IP | 260 | method, except it returns the IP |
| 222 | address and port as extra return values (and is therefore slightly less | 261 | address and port as extra return values (and is therefore slightly less |
| 223 | efficient). | 262 | efficient). |
| @@ -236,7 +275,7 @@ See <a href=#setoption><tt>setoption</tt></a> for | |||
| 236 | description of the option names and values. | 275 | description of the option names and values. |
| 237 | </p> | 276 | </p> |
| 238 | 277 | ||
| 239 | <p class="parameters"><tt>Option</tt> is a string with the option name. | 278 | <p class="parameters"><tt>Option</tt> is a string with the option name. |
| 240 | <ul> | 279 | <ul> |
| 241 | <li> '<tt>dontroute</tt>' | 280 | <li> '<tt>dontroute</tt>' |
| 242 | <li> '<tt>broadcast</tt>' | 281 | <li> '<tt>broadcast</tt>' |
| @@ -246,9 +285,9 @@ description of the option names and values. | |||
| 246 | <li> '<tt>ipv6-v6only</tt>' | 285 | <li> '<tt>ipv6-v6only</tt>' |
| 247 | <li> '<tt>ip-multicast-if</tt>' | 286 | <li> '<tt>ip-multicast-if</tt>' |
| 248 | <li> '<tt>ip-multicast-ttl</tt>' | 287 | <li> '<tt>ip-multicast-ttl</tt>' |
| 249 | <li> '<tt>ip-add-membership</tt>' | 288 | <li> '<tt>ip-add-membership</tt>' |
| 250 | <li> '<tt>ip-drop-membership</tt>' | 289 | <li> '<tt>ip-drop-membership</tt>' |
| 251 | </ul> | 290 | </ul> |
| 252 | </p> | 291 | </p> |
| 253 | 292 | ||
| 254 | <p class=return> | 293 | <p class=return> |
| @@ -268,7 +307,7 @@ Sends a datagram to the UDP peer of a connected object. | |||
| 268 | </p> | 307 | </p> |
| 269 | 308 | ||
| 270 | <p class="parameters"> | 309 | <p class="parameters"> |
| 271 | <tt>Datagram</tt> is a string with the datagram contents. | 310 | <tt>Datagram</tt> is a string with the datagram contents. |
| 272 | The maximum datagram size for UDP is 64K minus IP layer overhead. | 311 | The maximum datagram size for UDP is 64K minus IP layer overhead. |
| 273 | However datagrams larger than the link layer packet size will be | 312 | However datagrams larger than the link layer packet size will be |
| 274 | fragmented, which may deteriorate performance and/or reliability. | 313 | fragmented, which may deteriorate performance and/or reliability. |
| @@ -298,11 +337,11 @@ Sends a datagram to the specified IP address and port number. | |||
| 298 | 337 | ||
| 299 | <p class="parameters"> | 338 | <p class="parameters"> |
| 300 | <tt>Datagram</tt> is a string with the | 339 | <tt>Datagram</tt> is a string with the |
| 301 | datagram contents. | 340 | datagram contents. |
| 302 | The maximum datagram size for UDP is 64K minus IP layer overhead. | 341 | The maximum datagram size for UDP is 64K minus IP layer overhead. |
| 303 | However datagrams larger than the link layer packet size will be | 342 | However datagrams larger than the link layer packet size will be |
| 304 | fragmented, which may deteriorate performance and/or reliability. | 343 | fragmented, which may deteriorate performance and/or reliability. |
| 305 | <tt>Ip</tt> is the IP address of the recipient. | 344 | <tt>Ip</tt> is the IP address of the recipient. |
| 306 | Host names are <em>not</em> allowed for performance reasons. | 345 | Host names are <em>not</em> allowed for performance reasons. |
| 307 | 346 | ||
| 308 | <tt>Port</tt> is the port number at the recipient. | 347 | <tt>Port</tt> is the port number at the recipient. |
| @@ -337,9 +376,9 @@ object or vice versa. | |||
| 337 | For connected objects, outgoing datagrams | 376 | For connected objects, outgoing datagrams |
| 338 | will be sent to the specified peer, and datagrams received from | 377 | will be sent to the specified peer, and datagrams received from |
| 339 | other peers will be discarded by the OS. Connected UDP objects must | 378 | other peers will be discarded by the OS. Connected UDP objects must |
| 340 | use the <a href="#send"><tt>send</tt></a> and | 379 | use the <a href="#send"><tt>send</tt></a> and |
| 341 | <a href="#receive"><tt>receive</tt></a> methods instead of | 380 | <a href="#receive"><tt>receive</tt></a> methods instead of |
| 342 | <a href="#sendto"><tt>sendto</tt></a> and | 381 | <a href="#sendto"><tt>sendto</tt></a> and |
| 343 | <a href="#receivefrom"><tt>receivefrom</tt></a>. | 382 | <a href="#receivefrom"><tt>receivefrom</tt></a>. |
| 344 | </p> | 383 | </p> |
| 345 | 384 | ||
| @@ -421,16 +460,16 @@ only modify an option if you are sure you need it.</p> | |||
| 421 | name, and <tt>value</tt> depends on the option being set: | 460 | name, and <tt>value</tt> depends on the option being set: |
| 422 | </p> | 461 | </p> |
| 423 | 462 | ||
| 424 | <ul> | 463 | <ul> |
| 425 | <li> '<tt>dontroute</tt>': Indicates that outgoing | 464 | <li> '<tt>dontroute</tt>': Indicates that outgoing |
| 426 | messages should bypass the standard routing facilities. | 465 | messages should bypass the standard routing facilities. |
| 427 | Receives a boolean value; | 466 | Receives a boolean value; |
| 428 | <li> '<tt>broadcast</tt>': Requests permission to send | 467 | <li> '<tt>broadcast</tt>': Requests permission to send |
| 429 | broadcast datagrams on the socket. | 468 | broadcast datagrams on the socket. |
| 430 | Receives a boolean value; | 469 | Receives a boolean value; |
| 431 | <li> '<tt>reuseaddr</tt>': Indicates that the rules used in | 470 | <li> '<tt>reuseaddr</tt>': Indicates that the rules used in |
| 432 | validating addresses supplied in a <tt>bind()</tt> call | 471 | validating addresses supplied in a <tt>bind()</tt> call |
| 433 | should allow reuse of local addresses. | 472 | should allow reuse of local addresses. |
| 434 | Receives a boolean value; | 473 | Receives a boolean value; |
| 435 | <li> '<tt>reuseport</tt>': Allows completely duplicate | 474 | <li> '<tt>reuseport</tt>': Allows completely duplicate |
| 436 | bindings by multiple processes if they all set | 475 | bindings by multiple processes if they all set |
| @@ -442,7 +481,7 @@ datagram is delivered to the sending host as long as it is a | |||
| 442 | member of the multicast group. | 481 | member of the multicast group. |
| 443 | Receives a boolean value; | 482 | Receives a boolean value; |
| 444 | <li> '<tt>ipv6-v6only</tt>': | 483 | <li> '<tt>ipv6-v6only</tt>': |
| 445 | Specifies whether to restrict <tt>inet6</tt> sockets to | 484 | Specifies whether to restrict <tt>inet6</tt> sockets to |
| 446 | sending and receiving only IPv6 packets. | 485 | sending and receiving only IPv6 packets. |
| 447 | Receive a boolean value; | 486 | Receive a boolean value; |
| 448 | <li> '<tt>ip-multicast-if</tt>': | 487 | <li> '<tt>ip-multicast-if</tt>': |
| @@ -451,9 +490,9 @@ are sent. | |||
| 451 | Receives an IP address; | 490 | Receives an IP address; |
| 452 | <li> '<tt>ip-multicast-ttl</tt>': | 491 | <li> '<tt>ip-multicast-ttl</tt>': |
| 453 | Sets the Time To Live in the IP header for outgoing | 492 | Sets the Time To Live in the IP header for outgoing |
| 454 | multicast datagrams. | 493 | multicast datagrams. |
| 455 | Receives a number; | 494 | Receives a number; |
| 456 | <li> '<tt>ip-add-membership</tt>': | 495 | <li> '<tt>ip-add-membership</tt>': |
| 457 | Joins the multicast group specified. | 496 | Joins the multicast group specified. |
| 458 | Receives a table with fields | 497 | Receives a table with fields |
| 459 | <tt>multiaddr</tt> and <tt>interface</tt>, each containing an | 498 | <tt>multiaddr</tt> and <tt>interface</tt>, each containing an |
| @@ -463,7 +502,7 @@ group specified. | |||
| 463 | Receives a table with fields | 502 | Receives a table with fields |
| 464 | <tt>multiaddr</tt> and <tt>interface</tt>, each containing an | 503 | <tt>multiaddr</tt> and <tt>interface</tt>, each containing an |
| 465 | IP address. | 504 | IP address. |
| 466 | </ul> | 505 | </ul> |
| 467 | 506 | ||
| 468 | <p class="return"> | 507 | <p class="return"> |
| 469 | The method returns 1 in case of success, or | 508 | The method returns 1 in case of success, or |
| @@ -482,14 +521,14 @@ unconnected:<b>settimeout(</b>value<b>)</b> | |||
| 482 | </p> | 521 | </p> |
| 483 | 522 | ||
| 484 | <p class="description"> | 523 | <p class="description"> |
| 485 | Changes the timeout values for the object. By default, the | 524 | Changes the timeout values for the object. By default, the |
| 486 | <a href="#receive"><tt>receive</tt></a> and | 525 | <a href="#receive"><tt>receive</tt></a> and |
| 487 | <a href="#receivefrom"><tt>receivefrom</tt></a> | 526 | <a href="#receivefrom"><tt>receivefrom</tt></a> |
| 488 | operations are blocking. That is, any call to the methods will block | 527 | operations are blocking. That is, any call to the methods will block |
| 489 | indefinitely, until data arrives. The <tt>settimeout</tt> function defines | 528 | indefinitely, until data arrives. The <tt>settimeout</tt> function defines |
| 490 | a limit on the amount of time the functions can block. When a timeout is | 529 | a limit on the amount of time the functions can block. When a timeout is |
| 491 | set and the specified amount of time has elapsed, the affected methods | 530 | set and the specified amount of time has elapsed, the affected methods |
| 492 | give up and fail with an error code. | 531 | give up and fail with an error code. |
| 493 | </p> | 532 | </p> |
| 494 | 533 | ||
| 495 | <p class="parameters"> | 534 | <p class="parameters"> |
| @@ -524,7 +563,7 @@ imperative nature obvious. | |||
| 524 | <a href="index.html#download">download</a> · | 563 | <a href="index.html#download">download</a> · |
| 525 | <a href="installation.html">installation</a> · | 564 | <a href="installation.html">installation</a> · |
| 526 | <a href="introduction.html">introduction</a> · | 565 | <a href="introduction.html">introduction</a> · |
| 527 | <a href="reference.html">reference</a> | 566 | <a href="reference.html">reference</a> |
| 528 | </p> | 567 | </p> |
| 529 | <p> | 568 | <p> |
| 530 | <small> | 569 | <small> |
