From owner-freebsd-net@FreeBSD.ORG Thu Aug 6 08:38:06 2009 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2F12B1065673 for ; Thu, 6 Aug 2009 08:38:06 +0000 (UTC) (envelope-from denis.berezhnoy@gmail.com) Received: from mail-yx0-f181.google.com (mail-yx0-f181.google.com [209.85.210.181]) by mx1.freebsd.org (Postfix) with ESMTP id BAFE48FC08 for ; Thu, 6 Aug 2009 08:38:05 +0000 (UTC) Received: by yxe11 with SMTP id 11so863635yxe.3 for ; Thu, 06 Aug 2009 01:38:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=JPwmCn4T6BxWkeDz1XFn6d2LD907V42OHI6wlYpUaEE=; b=Q8kLsf9zVpMP93mCz/OyGi7s6+ErQuu3FyjdRu5J7ImZAUupOK69iLd6fJbMY64Fh7 1E1BRmJyPdWl/IZPGX2EFPWv6BfQMTqZ1c/hGNNY4mGkaivEJs+BlzqDUKCAQb4iU7E9 RXmTeSOmAUrW4vIeqqLQGydLOfzvIphx2Nwn4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=uSnugO1zD+/28RAkDleFPOvdKe6F2sJTV28XnId86G4tFN0Usq7+RDDYdn1Mtb0Pep XQc83WahaezLZp8u2Fj1fF4kk9x8Is5g1IlIq7OYSPa1PeZ/H/tlYtiYIF5OvV5Ei1VG yJaqEH7Jf8DqWIG3cPKJmLkRBjkFGHnVRDPJ4= MIME-Version: 1.0 Received: by 10.231.36.68 with SMTP id s4mr3206236ibd.47.1249546519696; Thu, 06 Aug 2009 01:15:19 -0700 (PDT) Date: Thu, 6 Aug 2009 17:15:19 +0900 Message-ID: <18b5e36e0908060115g76a56da3qb23fdd208e7c4a4c@mail.gmail.com> From: Denis Berezhnoy To: freebsd-net@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: kevent behavior with TCP socket X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Aug 2009 08:38:06 -0000 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