From: millert Date: Tue, 9 Aug 2016 17:34:06 +0000 (+0000) Subject: Expand the asynchronous connect information and move it out of X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8f804948172a6a09dad8e3c8a1f08da9f996adeb;p=openbsd Expand the asynchronous connect information and move it out of ERRORS and into a new second paragraph. Adapted from NetBSD. OK deraadt@ jmc@ --- diff --git a/lib/libc/sys/connect.2 b/lib/libc/sys/connect.2 index 897d487961e..165f537a94d 100644 --- a/lib/libc/sys/connect.2 +++ b/lib/libc/sys/connect.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: connect.2,v 1.28 2016/08/09 12:06:58 millert Exp $ +.\" $OpenBSD: connect.2,v 1.29 2016/08/09 17:34:06 millert Exp $ .\" $NetBSD: connect.2,v 1.8 1995/10/12 15:40:48 jtc Exp $ .\" .\" Copyright (c) 1983, 1993 @@ -74,6 +74,31 @@ only once; datagram sockets may use multiple times to change their association. Datagram sockets may dissolve the association by connecting to an invalid address, such as a null address. +.Pp +If the socket is in non-blocking mode and the connection cannot be +completed immediately, or if it is interrupted by a signal, +.Fn connect +will return an error and the connection attempt will proceed +asynchronously. +Subsequent calls to +.Fn connect +will fail with errno set to +.Er EALREADY . +It is possible to use +.Xr select 2 +or +.Xr poll 2 +to determine when the connect operation has completed by checking the +socket for writability. +The success or failure of the connection attempt may be determined by using +.Xr getsockopt 2 +to check the socket error status with the +.Dv SO_ERROR +option at the +.Dv SOL_SOCKET +level. +If the connection was successful, the error value will be zero. +Otherwise, it will be one of the error values listed below. .Sh RETURN VALUES If the connection or binding succeeds, 0 is returned. Otherwise a \-1 is returned, and a more specific error @@ -106,7 +131,7 @@ The attempt to connect was forcefully rejected. .It Bq Er EHOSTUNREACH The destination address specified an unreachable host. .It Bq Er EINTR -Connection establishment was interrupted by the delivery of a signal. +The connection attempt was interrupted by a signal. The attempt will continue asynchronously as if the socket was non-blocking. .It Bq Er ENETUNREACH The network isn't reachable from this host. @@ -118,20 +143,13 @@ The parameter specifies an area outside the process address space. .It Bq Er EINPROGRESS -The socket is non-blocking -and the connection cannot +The socket is non-blocking and the connection cannot be completed immediately. -It is possible to -.Xr select 2 -or -.Xr poll 2 -for completion by selecting the socket for writing, and also use -.Xr getsockopt 2 -with -.Dv SO_ERROR -to check for error conditions. .It Bq Er EALREADY -A previous connection attempt has not yet been completed. +Either the socket is non-blocking or a previous call to +.Fn connect +was interrupted by a signal, and the connection attempt has not yet +been completed. .El .Pp The following errors are specific to connecting names in the