.\" Modified 1998, 1999 by Andi Kleen
.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
.\"
-.TH CONNECT 2 2016-12-12 "Linux" "Linux Programmer's Manual"
+.TH CONNECT 2 2019-03-06 "Linux" "Linux Programmer's Manual"
.SH NAME
connect \- initiate a connection on a socket
.SH SYNOPSIS
.BR "#include <sys/types.h>" " /* See NOTES */"
.br
.B #include <sys/socket.h>
-.sp
+.PP
.BI "int connect(int " sockfd ", const struct sockaddr *" addr ,
.BI " socklen_t " addrlen );
.fi
see
.BR socket (2)
for further details.
-
+.PP
If the socket
.I sockfd
is of type
field.
.TP
.B EAGAIN
-Insufficient entries in the routing cache.
+For nonblocking UNIX domain sockets, the socket is nonblocking, and the
+connection cannot be completed immediately.
+For other socket families, there are insufficient entries in the routing cache.
.TP
.B EALREADY
The socket is nonblocking and a previous connection attempt has not yet
is not a valid open file descriptor.
.TP
.B ECONNREFUSED
-No-one listening on the remote address.
+A
+.BR connect ()
+on a stream socket found no one listening on the remote address.
.TP
.B EFAULT
The socket structure address is outside the user's address space.
.TP
.B EINPROGRESS
-The socket is nonblocking and the connection cannot be completed
-immediately.
+The socket is nonblocking and the connection cannot be completed immediately.
+(UNIX domain sockets failed with
+.BR EAGAIN
+instead.)
It is possible to
.BR select (2)
or
Note that for IP sockets the timeout may
be very long when syncookies are enabled on the server.
.SH CONFORMING TO
-POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD, (the
-.BR connect ()
-function first appeared in 4.2BSD).
+POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD,
+.RB (connect ()
+first appeared in 4.2BSD).
.\" SVr4 documents the additional
.\" general error codes
.\" .BR EADDRNOTAVAIL ,
and this header file is not required on Linux.
However, some historical (BSD) implementations required this header
file, and portable applications are probably wise to include it.
-
+.PP
For background on the
.I socklen_t
type, see
.BR accept (2).
-
+.PP
If
.BR connect ()
fails, consider the state of the socket as unspecified.