From owner-freebsd-questions Tue Oct 8 14: 1:59 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6502437B401 for ; Tue, 8 Oct 2002 14:01:58 -0700 (PDT) Received: from cactus.fi.uba.ar (cactus.fi.uba.ar [157.92.49.108]) by mx1.FreeBSD.org (Postfix) with ESMTP id 50AFE43E4A for ; Tue, 8 Oct 2002 14:01:57 -0700 (PDT) (envelope-from fgleiser@cactus.fi.uba.ar) Received: from cactus.fi.uba.ar (cactus.fi.uba.ar [157.92.49.108]) by cactus.fi.uba.ar (8.12.3/8.12.3) with ESMTP id g98KxjAO017888; Tue, 8 Oct 2002 17:59:45 -0300 (ART) (envelope-from fgleiser@cactus.fi.uba.ar) Date: Tue, 8 Oct 2002 17:59:44 -0300 (ART) From: Fernando Gleiser To: alireza mahini Cc: questions@freebsd.org Subject: Re: How i can force a stream socket to wait as limited time in accept() function? In-Reply-To: <20021008200436.90193.qmail@web40709.mail.yahoo.com> Message-ID: <20021008175344.I3949-100000@cactus.fi.uba.ar> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-3.5 required=5.0 tests=IN_REP_TO,SUBJ_ENDS_IN_Q_MARK version=2.31 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 8 Oct 2002, alireza mahini wrote: > I am a C++ programmer and the platform that i develop > my project on it is FreeBSD4.4 .I am aplaying the > setsocketopt()function for seting the timeout into the > stream socket that blocked in accept() function but i > can't successful. It's easy, mmmkay :) You need to set the socket descriptor in non-blocking mode, then call accept. accept will fail and return -1 with errno set to EWOULDBLOCK, the call select(2) on the socket. select will return when a connection arrives (you need to test for it) or when the timeout expires. I (and everybody else) recommend "Unix Network Programming, 2d Ed" by Rich Stevens. It is THE book for unix programmers. Fer > > __________________________________________________ > Do you Yahoo!? > Faith Hill - Exclusive Performances, Videos & More > http://faith.yahoo.com > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message