4:55 C ˆl–äY>”ªe¶… @;pÜ Å£Á „@¿_‡I|¥‰ÓMa–Ãa¾”*j"Tâ�vãnÜiå1hßÅ ?÷
server:accept()
Waits for a remote connection on the server object and returns a client object representing that connection.
If a connection is successfully initiated, a client object is returned. If a timeout condition is met, the method returns nil followed by the error string 'timeout'. Other errors are reported by nil followed by a message describing the error.
Note: calling socket.select with a server object in the recvt parameter before a call to accept does not guarantee accept will return immediately. Use the settimeout method or accept might block until another client shows up.
master:bind(address, port)
Binds a master object to address and port on the local host.
Address can be an IP address or a host name. Port must be an integer number in the range [0..64K). If address is '*', the system binds to all local interfaces using the INADDR_ANY constant or IN6ADDR_ANY_INIT, according to the family. If port is 0, the system automatically chooses an ephemeral port.
In case of success, the method returns 1. In case of error, the method returns nil followed by an error message.
Note: The function socket.bind is available and is a shortcut for the creation of server sockets.
master:close()
client:close()
server:close()
Closes a TCP object. The internal socket used by the object is closed and the local address to which the object was bound is made available to other applications. No further operations (except for further calls to the close method) are allowed on a closed socket.
Note: It is important to close all used sockets once they are not needed, since, in many systems, each socket uses a file descriptor, which are limited system resources. Garbage-collected objects are automatically closed before destruction, though.