Re: detecting a closing socket from a Lex/Yacc interpreter ?

2001-02-23 Thread Thierry Herbelot

Jordan DeLong wrote:
> 
> 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.
> 

indeed, taking the very simple YY_INPUT code from the man page of lex
did the trick (+ remembering to close the fd's associated to the socket
...)

Thanks

-- 
Thierry Herbelot

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: detecting a closing socket from a Lex/Yacc interpreter ?

2001-02-22 Thread Jordan DeLong

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 [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



detecting a closing socket from a Lex/Yacc interpreter ?

2001-02-22 Thread Thierry Herbelot

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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message