Date: Thu, 6 Aug 2009 17:15:19 +0900 From: Denis Berezhnoy <denis.berezhnoy@gmail.com> To: freebsd-net@freebsd.org Subject: kevent behavior with TCP socket Message-ID: <18b5e36e0908060115g76a56da3qb23fdd208e7c4a4c@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hi guys, I have question regarding kevent behavior with TCP socket. Hope you can advise anything. I am trying to connect the server in non block mode. When I call connect it returns -1 and errno=EINPROGRESS. Then I use kqueue and kevent with EVFILT_WRITE and timeout 100 msec to wait when server will be available to accept connection. kevent returns me 1 event without any timeout (filters = -2 (EVFILT_WRITE) flags = 0 data = 43008) So I consider this as server is ready to accept connection but when I check socket error after kevent returns by getsockopt with SOL_SOCKET and SO_ERROR params it returns me socket error 54 ECONNRESET /* Connection reset by peer */ and no connection can be established using this socket. I am confused why kevent returns event that seems to indicate good condition but actual socket status indicates error. What I am doing wrong? Sorry for this rough description of the problem my code is the part of large system so I can not simply copy paste code. I am using: FreeBSD freebsd 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan 1 14:37:25 UTC 2009 root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 Best regards Denis
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?18b5e36e0908060115g76a56da3qb23fdd208e7c4a4c>