Date: Thu, 1 Feb 2001 16:39:35 -0800 From: "Jonathan Graehl" <jonathan@graehl.org> To: <freebsd-arch@freebsd.org> Cc: "Jonathan Lemon" <jlemon@freebsd.org> Subject: socket connect status from kqueue events? Message-ID: <NCBBLOALCKKINBNNEDDLEEEHDKAA.jonathan@graehl.org>
next in thread | raw e-mail | index | archive | help
How are TCP connect failures (timed out, connection refused, icmp error) reflected in the corresponding kqueue event? I can determine when a connection call has completed by using EVFILT_WRITE (the socket is immediately writable when connected), but other than checking for ENOTCONN or ECONNRESET using getpeername(fd,NULL,0), I don't know how I can determine whether the connect succeeded or not, and, if it didn't, what the cause was (ICMP errors followed by timeout, timeout with no response, or RST immediately ending attempt). I would prefer not to use getpeername. I suppose I could also attempt to do something with the possibly-connected socket, and wait for an error on failure, or do getsockopt(SO_ERROR...), which might possibly give me the actual error resulting from the failed connect attempt? Please tell me there is a flag somewhere in the event structure for an EVFILT_WRITE event which can indicate at least whether the connection has failed or not (there is a difference between the other end closing immediately, which should show up as EV_EOF, and the connection never being established in the first place). Also, are there any plans to allow for local and remote endpoints to both be specified before bind/listen/connect, to avoid the excessive use of SO_REUSEADDR? -- Jonathan Graehl email: jonathan@graehl.org web: http://jonathan.graehl.org/ phone: 858-642-7562 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?NCBBLOALCKKINBNNEDDLEEEHDKAA.jonathan>