From bf738a03368b8de9c574d9631f131c5a520acf7b Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Wed, 26 May 2004 04:58:32 +0000 Subject: Working with in the manual. --- doc/socket.html | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 2 deletions(-) (limited to 'doc/socket.html') diff --git a/doc/socket.html b/doc/socket.html index 9372648..bde882b 100644 --- a/doc/socket.html +++ b/doc/socket.html @@ -33,7 +33,7 @@ -

The LuaSocket namespace

+

The socket namespace

The socket namespace contains the namespace tables for all @@ -74,7 +74,120 @@ The function an equivalent function that instead of throwing exceptoins, returns nil followed by an error message.

- + + +

+socket.select(recvt, sendt [, timeout]) +

+ +

+Waits for a number of sockets to change status. +

+ +

+Recvt is an array with the sockets to test for characters +available for reading. Sockets in the sendt array are watched to +see if it is OK to immediately write on them. Timeout is the +maximum amount of time (in seconds) to wait for a change in status. A +nil, negative or omitted timeout value allows the +function to block indefinitely. Recvt and sendt can also +be empty tables or nil. Non-socket values in the arrays +will be silently ignored. +

+ +

The function returns a table with the sockets ready for +reading, a table with the sockets ready for writing and an error message. +The error message is "timeout" if a timeout condition was met and +nil otherwise. The returned tables are associative, to +simplify the test if a specific socket has changed status. +

+ +

+Important Note: a known bug in WinSock causes select to fail +on non-blocking TCP sockets. The function may return a socket as +writable even though the socket is not ready for sending. +

+ +

+Important note: calling select with a server socket in the receive +parameter before a call to accept does not guarantee +accept will return immediately. +Use the timeout +method or accept might block forever. +

+ +

+Interesting note: as mentioned in some manuals, calling select with both +sets empty and a non-null timeout is a fairly portable way to sleep with +sub-second precision. +

+ + + + +

+socket.sink(mode, socket) +

+ +

+Creates an +LTN012 +sink from a stream socket object. +

+ +

+Mode defines the behaviour of the sink. The following +options are available: +

+ +

+Socket is the stream socket object used to send the data. +

+ +

+The function returns a sink with the appropriate behavior. +

+ + + +

+socket.source(mode, socket [, length]) +

+ +

+Creates an +LTN012 +source from a stream socket object. +

+ +

+Mode defines the behaviour of the source. The following +options are available: +

+ +

+Socket is the stream socket object used to receive the data. +

+ +

+The function returns a source with the appropriate behavior. +

+ +

socket.try(ret1, ret2 ... retN) -- cgit v1.2.3-55-g6feb