From owner-freebsd-hackers Thu Feb 22 13:18:38 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from cx420564-b.tucson1.az.home.com (cx420564-b.tucson1.az.home.com [24.21.112.225]) by hub.freebsd.org (Postfix) with ESMTP id D2F7837B401 for ; Thu, 22 Feb 2001 13:18:34 -0800 (PST) (envelope-from fracture@cx420564-b.tucson1.az.home.com) Received: (from fracture@localhost) by cx420564-b.tucson1.az.home.com (8.11.1/8.11.1) id f1MEACi09466; Thu, 22 Feb 2001 14:10:12 GMT (envelope-from fracture) Date: Thu, 22 Feb 2001 14:09:11 +0000 From: Jordan DeLong To: Thierry Herbelot Cc: hackers@FreeBSD.ORG Subject: Re: detecting a closing socket from a Lex/Yacc interpreter ? Message-ID: <20010222140911.A9405@cx420564-b.tucson1.az.home.com> References: <3A95776A.1E76A7B@free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3A95776A.1E76A7B@free.fr>; from thierry.herbelot@free.fr on Thu, Feb 22, 2001 at 09:32:42PM +0100 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I'm assuming right now you are just setting yyin to the fd for the socket. What you're gonna want to do is define the macro YY_INPUT (see the man page for details) so that it calls recv on your socket. and then if it errors you can have YY_INPUT return as an EOF and your <> rule will work fine. On Thu, Feb 22, 2001 at 09:32:42PM +0100, Thierry Herbelot wrote: > Hello, > > I'm currently writing a small interpreter for a client/server > application. > > the Lex and Yacc files seem to be OK, as the tests are running fine (as > long as there is only one client, and the client dos not close its > socket ...) > > I still have one problem : the server has a single thread : the process > accept()s a connection, then processes the commands (with yyparse()), > and after the current client disconnects, gets back to listening to the > socket, and so on. > > the problem is that the yyparse() function does not return when the > socket is closed. I've had a look at the sources of ftpd, where yacc is > used, but from what I've seen, the yylex() function has been hand > written (which I would like not to do) > > I've added a <> target in the lex file, but it does not seem to > detect the socket close() > > taker for any solution, > > TfH > -- > Thierry Herbelot > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message