A Scripting Language for Web, Linux and Windows

A Scripting Language for Web, Linux and Windows

Socket functions

The following socket functions are supported. Socket handles can be used with file I/O functions. See also chapter File functions.

Function/Arguments Return Description
fsockopen (string host, number port, number rcvTimeout=0) handle Open a TCP/IP client socket and connect to a specified host and port. Optional parameter rcvTimeout set the timeout in milliseconds data should be received from socket (0=no timeout). On success the socket handle is returned, otherwise null is returned and a warning is shown.
fsockserver (string host, number port, number backlog=10) handle Create a TCP/IP server socket on a specified host and port. On success the socket handle is returned, otherwise null is returned and a warning is shown The optional backlog parameter set the number of possible waiting clients in background until fsockaccept() return a new client socket.
fsockaccept (handle socket, number rcvTimeout=0) handle Accept a new connection on a TCP/IP server socket. On success the new client socket handle is returned, otherwise null is returned and a warning is shown. Optional parameter rcvTimeout set the timeout in milliseconds data should be received from new client socket (0=no timeout).
fclose (handle socket) bool Shutdown and close a given socket. On success true is returned.
fsockip (handle socket) string Return the IPV4 address of a given socket.
fsockport (handle socket) number Return the port number of a given socket.
gethostbyaddr (string ipaddress) string Lookup the hostname of a ipaddress (IPV4). On success the hostname is returned, otherwise false is returned.
gethostbyname (string hostname) string Lookup the IPV4 address of a hostname. On success the IP address is returned, otherwise false is returned.

Socket I/O functions:

Function/Arguments Return Description
fwrite (handle socket, string string [, number length]) number Write a string into the given socket . If parameter length is not given then the full string is written, otherwise the specified number of bytes are written. On success the number of written bytes is returned. If the peer connection was closed false is returned.
fread (handle socket, string& string [, number length=0xFFFF]) number Read data from the given socket into a string variable. The parameter string must be a reference to a variable. If length is not set then it tries to read 64 KB from the socket. On success the number of read bytes is returned. I the peer connection was closed or timeout occurred false is returned.
fgets (handle socket) string Read a line until Ascii 13=\n from socket . On success the read line is returned. If the peer connection was closed or timeout occurred false is returned.
freadln (handle socket, string& string) bool Read a line until Ascii 13=\n from socket into a given string variable. The parameter string must be a reference to a variable. On success true is returned. If the peer connection was closed or timeout occurred false is returned.

back to Home

V1 Version 0.95 - Documentation generated Sun, 02 Dec 2018 16:29