MAN page from Old RedHat 5.X man-pages-1.21-1.noarch.rpm
CONNECT
Section: Linux Programmer's Manual (2)
Updated: 23 July 1993
Index NAME
connect - initiate a connection on a socket
SYNOPSIS
#include <sys/types.h>#include <sys/socket.h>int connect(int sockfd, struct sockaddr *serv_addr, int addrlen );
DESCRIPTION
The parameter
sockfdis a socket.If it is of type
SOCK_DGRAM,this call specifies the peer with which the socket is to be associated;this address is that to which datagrams are to be sent, and the onlyaddress from which datagrams are to be received. If the socket is of type
SOCK_STREAM ,this call attempts to make a connection to another socket. The othersocket is specified by
serv_addr,which is an address in the communications space of the socket. Eachcommunications space interprets the
serv_addr,parameter in its own way. Generally, stream sockets may successfully
connectonly once; datagram sockets may use
connectmultiple times to change their association. Datagram sockets may dissolvethe association by connecting to an invalid address, such as a nulladdress.
RETURN VALUE
If the connection or binding succeeds, zero is returned. On error, -1 isreturned, and
errnois set appropriately.
ERRORS
The following are general socket errors only. There may be otherdomain-specific error codes.
- EBADF
- Bad descriptor.
- EFAULT
- The socket structure address is outside your address space.
- ENOTSOCK
- The descriptor is not associated with a socket.
- EISCONN
- The socket is already connected.
- ECONNREFUSED
- Connection refused at server.
- ETIMEDOUT
- Timeout while attempting connection.
- ENETUNREACH
- Network is unreachable.
- EADDRINUSE
- Address is already in use.
- EINPROGRESS
- The socket is non-blocking and the connection cannot be completedimmediately. It is possible toselect(2)for completion by selecting the socket for writing. After selectindicates writability, usegetsockopt(2)to read the SO_ERROR option at level SOL_SOCKET to determinewhether connect completed successfully (SO_ERROR is zero) orunsuccessfully (SO_ERROR is one of the usual error codes listedabove, explaining the reason for the failure).
- EALREADY
- The socket is non-blocking and a previous connection attempt has not yetbeen completed.
CONFORMING TO
SVr4, 4.4BSD (the
connectfunction first appeared in BSD 4.2). SVr4 documents additionalgeneral error codes EADDRNOTAVAIL, EINVAL, EAFNOSUPPORT, EALREADY, EINTR, EPROTOTYPE, ENOSR. It alsodocuments many additional error conditions not described here.
SEE ALSO
accept(2),
bind(2),
listen(2),
socket(2),
getsockname(2)
Index
- NAME
- SYNOPSIS
- DESCRIPTION
- RETURN VALUE
- ERRORS
- CONFORMING TO
- SEE ALSO
This document was created byman2html,using the manual pages.