.\"create an efun socket .DT socket_create $MUDNAME$ driver help socket_create .SH Name .SI 5 socket_create() - create an efun socket .EI .SH Synopsis .SI 5 #include <socket_errors.h> int socket_create( int mode, string | function read_callback ); int socket_create( int mode, string | function read_callback, string | function close_callback ); .EI .SH Description .SP 5 5 socket_create() creates an efun socket. `mode' determines which type of socket is created. Currently supported socket modes are: .EP .SO 10 15 45 MUD for sending LPC data types using TCP protocol. STREAM for sending raw data using TCP protocol. DATAGRAM for using UDP protocol. .EO .SP 5 5 The argument `read_callback' is the function or the name of a function for the driver to call when the socket gets data from its peer. The read callback should follow this format: .EP .SI 5 void read_callback( int fd, mixed message ) .EI .SP 5 5 Where `fd' is the socket which received the data, and `message' is the data which was received. The argument `close_callback' is the function or the name of a function for the driver to call if the socket closes unexpectedly, i.e. not as the result of a socket_close() call. The close callback should follow this format: .EP .SI 5 void close_callback( int fd ) .EI .SP 5 5 Where fd is the socket which has closed. NOTE: `close_callback' is not used with DATAGRAM mode sockets. socket_create() returns a non-negative descriptor on success, and a negative value indicated below on error. .EP .SH Errors .SI 5 These errors are in <socket_errors.h>: .EI .SO 10 15 45 EEMODENOTSUPP Socket mode not supported. EESOCKET Problem creating socket. EESETSOCKOPT Problem with setsockopt. EENONBLOCK Problem setting non-blocking mode. EENOSOCKS No more available efun sockets. EESECURITY Security violation attempted. .EO .SH See also .SI 5 socket_accept(), socket_bind(), socket_close(), socket_connect(), socket_listen(), socket_write() .EI