SPL Socket Module This Module provides basic functions for handling TCP sockets.builtin socket_create(host,port);
Create an initial socket and connect to given host. Returns the handle of the connected socket or 0 on failure.
Establish a server socket; originally from firstname.lastname@example.org The port number is the only parameter needed for this function. Note that server sockets should not be used for read/write. Rather use socket_accept(server) to accept incoming connections that can be used for communication.
Accept incoming connections on a server socket. Use socket_server(port) to create an initial server socket that can accept incoming connection. To determine if pending connections are available, use socket_poll(server).
Write data to given socket. Note: can raise a SocketEx exception Returns number of bytes written
Poll socket for available data. Returns 1 if bytes are available for non-blocking read, 0 otherwise. On error, -1 is returned;
Read data from socket. Note: can raise a SocketEx exception Returns the string that was read To achieve good read performance, it is suggested to use socket_poll() to check if bytes are available for non-blocking read and to use socket_read with a reasonably big buffer like 1000 bytes. The buffer size is specified with the length parameter. Available bytes are read into the buffer until the buffer is full or no further data is available at that moment to avoid blocking. Note: socket_read() will block until some data is available if there is no data available initially. Note: Not tested with binary data. SPL is string oriented.
SocketEx exception. This can be thrown by read and write to signal an error.
|Generated by SPLDOC.||http://www.clifford.at/spl/|