Skip to main content

socket_listen

Discworld driver help

socket_listen

Name

socket_listen() - listen for connections on a socket

Synopsis

#include <socket_errors.h>

int socket_listen( int s, string | function listen_callback );

Description

To accept connections, a socket is first created with socket_create(), the socket is then put into listening mode with socket_listen(), and the connections are accepted with socket_accept(). The socket_listen() call applies only to sockets of type STREAM or MUD.

The argument `listen_callback' is the function or the name of a function for the driver to call when a connection is requested on the listening socket. The listen callback should follow this format:

void listen_callback( int fd )

Where fd is the listening socket.

socket_listen() returns EESUCCESS on success, and a negative value indicated below on error.

Errors

These errors are in <socket_errors.h>:

EEFDRANGEDescriptor out of range.
EEBADFDescriptor is invalid.
EESECURITYSecurity violation attempted.
EEMODENOTSUPPSocket mode not supported.
EENOADDRSocket not bound to an address.
EEISCONNSocket is already connected.
EELISTENProblem with listen.

See also

socket_accept(), socket_connect(), socket_create()