.\"initiate a connection on a socket
.DT
socket_connect
$MUDNAME$ driver help
socket_connect

.SH Name
.SI 5
socket_connect() - initiate a connection on a socket
.EI

.SH Synopsis
.SI 5
#include <socket_errors.h>

int socket_connect( int s, string address,
		    string | function read_callback,
		    string | function write_callback );
.EI

.SH Description
.SP 5 5
The argument `s' is a socket.  `s' must be either a STREAM mode or a MUD mode
socket.  `address' is the address to which the socket will attempt to connect.
`address' is of the form: "127.0.0.1 23"

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 `write_callback' is the function or the name of a function for
the driver to call when the socket is ready to be written to.  The write
callback should follow this format:
.EP

.SI 5
void write_callback( int fd )
.EI

.SP 5 5
Where fd is the socket which is ready to be written to.

socket_connect() returns EESUCCESS 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
	EEFDRANGE	Descriptor out of range.
	EEBADF	Descriptor is invalid.
	EESECURITY	Security violation attempted.
	EEMODENOTSUPP	Socket mode not supported.
	EEISLISTEN	Socket is listening.
	EEISCONN	Socket is already connected.
	EEBADADDR	Problem with address format.
	EEINTR	Interrupted system call.
	EEADDRINUSE	Address already in use.
	EEALREADY	Operation already in progress.
	EECONNREFUSED	Connection refused.
	EECONNECT	Problem with connect.
.EO

.SH See also
.SI 5
socket_accept(), socket_close(), socket_create()
.EI
