Hello, the manual page does not describe the state of a socket after a failed connect call. Surprisingly, there are TCP/IP stacks where it is unusable (met one today). Opengroup also specifies that as allowed behaviour, so the manual should mention it. Michael
--- /usr/share/man/man2/connect.2 2014-08-18 18:48:29.894304874 +0200 +++ ./connect.2 2014-08-18 18:53:24.945090422 +0200 @@ -63,8 +63,9 @@ .\" Modified 1997-01-31 by Eric S. Raymond <esr@xxxxxxxxxxx> .\" Modified 1998, 1999 by Andi Kleen .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@xxxxxxxxx> +.\" Modified 2014-08-18 by Michael Haardt <michael@xxxxxxxx> .\" -.TH CONNECT 2 2014-07-08 "Linux" "Linux Programmer's Manual" +.TH CONNECT 2 2014-08-14 "Linux" "Linux Programmer's Manual" .SH NAME connect \- initiate a connection on a socket .SH SYNOPSIS @@ -267,6 +268,12 @@ also used by glibc. See also .BR accept (2). + +Although it works in Linux, if +.B connect() +fails, consider the state of the socket as unspecified. Portable +applications should close the socket and create a new one for +reconnecting. .SH EXAMPLE An example of the use of .BR connect ()