initiate a connection on a socket
cc ... -lsocket
int connect (s, name, namelen)
const struct sockaddr *name;
initiates a connection on a socket.
The s parameter is a socket.
If it is of type SOCK_DGRAM,
then this call permanently specifies the peer to which
datagrams are to be sent;
if it is of type SOCK_STREAM,
then this call attempts to make a connection to another socket.
The other socket is specified by name;
namelen is the length of name,
which is an address in the address family of the socket.
Each address family interprets the name parameter
in its own way.
A return value of zero indicates that the call succeeded.
A return value of -1 indicates that an error occurred, and in this
case an error code is stored in the global variable errno.
The call fails if:
The s argument
is not a valid descriptor.
The s argument
is a descriptor for a file, not a socket.
The specified address is not available on this machine.
Addresses in the specified address family cannot be used with this socket.
The socket is already connected.
Connection establishment timed out without establishing a connection.
The attempt to connect was forcefully rejected.
The network is not reachable from this host.
The destination host is not reachable from this host.
The address is already in use.
The name parameter specifies an area outside
the process address space.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003