connect man page on Archlinux

Man page or keyword search:  
man Server   11224 pages
apropos Keyword Search (all sections)
Output format
Archlinux logo
[printable version]

CONNECT(3P)		   POSIX Programmer's Manual		   CONNECT(3P)

PROLOG
       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
       implementation of this interface may differ (consult the	 corresponding
       Linux  manual page for details of Linux behavior), or the interface may
       not be implemented on Linux.

NAME
       connectconnect a socket

SYNOPSIS
       #include <sys/socket.h>

       int connect(int socket, const struct sockaddr *address,
	   socklen_t address_len);

DESCRIPTION
       The connect() function shall attempt to make a connection on a  connec‐
       tion-mode  socket  or to set or reset the peer address of a connection‐
       less-mode socket. The function takes the following arguments:

       socket	   Specifies the file descriptor associated with the socket.

       address	   Points to a sockaddr structure containing the peer address.
		   The	length and format of the address depend on the address
		   family of the socket.

       address_len Specifies the length of the sockaddr structure  pointed  to
		   by the address argument.

       If  the socket has not already been bound to a local address, connect()
       shall bind it to an address which, unless the socket's  address	family
       is AF_UNIX, is an unused local address.

       If  the	initiating socket is not connection-mode, then connect() shall
       set  the	 socket's  peer	 address,  and	no  connection	is  made.  For
       SOCK_DGRAM sockets, the peer address identifies where all datagrams are
       sent on subsequent send() functions, and limits the remote  sender  for
       subsequent  recv()  functions.  If  the	sa_family member of address is
       AF_UNSPEC, the socket's peer address shall be reset. Note that  despite
       no  connection being made, the term ``connected'' is used to describe a
       connectionless-mode socket for which a peer address has been set.

       If the initiating  socket  is  connection-mode,	then  connect()	 shall
       attempt	to  establish  a  connection  to  the address specified by the
       address argument. If the connection cannot be  established  immediately
       and  O_NONBLOCK is not set for the file descriptor for the socket, con‐
       nect() shall block for up to an unspecified timeout interval until  the
       connection  is  established. If the timeout interval expires before the
       connection is established, connect()  shall  fail  and  the  connection
       attempt	shall be aborted. If connect() is interrupted by a signal that
       is caught while blocked waiting to establish  a	connection,  connect()
       shall  fail  and set errno to [EINTR], but the connection request shall
       not be aborted, and the connection shall be established asynchronously.

       If the connection cannot be established immediately and	O_NONBLOCK  is
       set  for	 the  file descriptor for the socket, connect() shall fail and
       set errno to [EINPROGRESS], but the connection  request	shall  not  be
       aborted, and the connection shall be established asynchronously. Subse‐
       quent calls to connect() for the same socket, before the connection  is
       established, shall fail and set errno to [EALREADY].

       When  the  connection  has  been established asynchronously, pselect(),
       select(), and poll() shall indicate that the file  descriptor  for  the
       socket is ready for writing.

       The  socket  in	use may require the process to have appropriate privi‐