<HEAD> <TITLE> socket_connect - initiate a connection on a socket </TITLE> </HEAD> <BODY BACKGROUND=http://www.imaginary.com/~beek/gifs/bg.jpg TEXT=#000000 ALINK=#FFFF00 VLINK=#550000 LINK=#000099> <center> <H1> socket_connect - initiate a connection on a socket </H1> </center>
<p>
<b> int socket_connect( int s, string address,
string read_callback,
string write_callback ); </b>
<p>
This efun is only available if PACKAGE_SOCKETS is compiled in.
<p>
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"
<p>
The argument read_callback is 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:
<p>
<pre>
void read_callback(int fd, mixed message)
</pre>
<p>
Where fd is the socket which received the data, and message is the data
which was received.
<p>
The argument write_callback is 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:
<p>
<pre>
void write_callback(int fd)
</pre>
<p>
Where fd is the socket which is ready to be written to.
<p>
socket_connect() returns:
<p>
EESUCCESS on success.
<p>
a negative value indicated below on error.
<p>
ERRORS - these are in "socket_err.h"
<p>
<DL>
<DT> <IMG SRC = http://www.imaginary.com/Graphics/Whiteball.gif> EEFDRANGE Descriptor out of range.
<DT> <IMG SRC = http://www.imaginary.com/Graphics/Whiteball.gif> EEBADF Descriptor is invalid.
<DT> <IMG SRC = http://www.imaginary.com/Graphics/Whiteball.gif> EESECURITY Security violation attempted.
<DT> <IMG SRC = http://www.imaginary.com/Graphics/Whiteball.gif> EEMODENOTSUPP Socket mode not supported.
<DT> <IMG SRC = http://www.imaginary.com/Graphics/Whiteball.gif> EEISLISTEN Socket is listening.
<DT> <IMG SRC = http://www.imaginary.com/Graphics/Whiteball.gif> EEISCONN Socket is already connected.
<DT> <IMG SRC = http://www.imaginary.com/Graphics/Whiteball.gif> EEBADADDR Problem with address format.
<DT> <IMG SRC = http://www.imaginary.com/Graphics/Whiteball.gif> EEINTR Interrupted system call.
<DT> <IMG SRC = http://www.imaginary.com/Graphics/Whiteball.gif> EEADDRINUSE Address already in use.
<DT> <IMG SRC = http://www.imaginary.com/Graphics/Whiteball.gif> EEALREADY Operation already in progress.
<DT> <IMG SRC = http://www.imaginary.com/Graphics/Whiteball.gif> EECONNREFUSED Connection refused.
<DT> <IMG SRC = http://www.imaginary.com/Graphics/Whiteball.gif> EECONNECT Problem with connect.
</DL>
<p>
See also:
<A HREF=socket_accept.html> socket_accept </A>,
<A HREF=socket_close.html> socket_close </A>,
<A HREF=socket_create.html> socket_create </A>
<p>
<HR> <ADDRESS> <A HREF=http://wagner.princeton.edu/~tim> Tim Hollebeek </A> <p> <A HREF="http://www.imaginary.com/~beek/"> Beek </A>@ZorkMUD, Lima Bean, IdeaExchange, TMI-2, and elsewhere </ADDRESS>
<p>