Initialize the socket API. Must be called at least once per process
before using any socket or host function.
'socketsocket_new(udp : bool)Create a new socket, TCP or UDPvoidsocket_close('socket)Close a socket. Any subsequent operation on this socket will failvoidsocket_send_char('socket, int)Send a character over a connected socket. Must be in the range 0..255intsocket_send('socket, buf : string, pos : int, len : int)Send up to len bytes from buf starting at pos over a connected socket.
Return the number of bytes sent.intsocket_recv('socket, buf : string, pos : int, len : int)Read up to len bytes from buf starting at pos from a connected socket.
Return the number of bytes readed.intsocket_recv_char('socket)Read a single char from a connected socket.voidsocket_write('socket, string)Send the whole content of a string over a connected socket.stringsocket_read('socket)Read the whole content of a the data available from a socket until the connection close.
If the socket hasn't been close by the other side, the function might block.
'int32host_resolve(string)Resolve the given host string into an IP address.stringhost_to_string('int32)Return a string representation of the IP address.stringhost_reverse('int32)Reverse the DNS of the given IP address.stringhost_local()Return the local host name.voidsocket_connect('socket, host : 'int32, port : int)Connect the socket the given host and portvoidsocket_listen('socket, int)Listen for a number of connections'socket array arraysocket_select(read : 'socket array, write : 'socket array, others : 'socket array, timeout : number?)Perform the select operation. Timeout is in seconds or null if infinitevoidsocket_bind('socket, host : 'int32, port : int)Bind the socket for server usage on the given host and port'socketsocket_accept('socket)Accept an incoming connection request#addresssocket_peer('socket)Return the socket connected peer address composed of an (host,port) array#addresssocket_host('socket)Return the socket local address composed of an (host,port) arrayvoidsocket_set_timeout('socket, timout : number?)Set the socket send and recv timeout in seconds to the given value (or null for blocking)voidsocket_shutdown('socket, read : bool, write : bool)Prevent the socket from further reading or writing or both.voidsocket_set_blocking('socket, bool)Turn on/off the socket blocking mode.'pollsocket_poll_alloc(int)Allocate memory to perform polling on a given number of sockets'socket arraysocket_poll('socket array, 'pool, timeout : float)
Perform a polling for data available over a given set of sockets. This is similar to socket_select
except that socket_select is limited to a given number of simultaneous sockets to check.