[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Simple client. How to handle login prompts.



I'll answer my own questions.

I wrote:
> Here comes all my questions:
> * Am I on the right track?

Yes, right track. But there was a tiny misconception.

> * I also try to read the lines in the handle callback evbuffer_readln(), but the lines will then bre printed in the wrong order. Why?

The problem is that the buffer is not line based. but rather based on consecutive bytes. evebuffer_readln() reads what is in the buffer up to the next Line termination. (CR, CRLF or whatever specified.)

> * The login prompt from the server does not send a newline, so the handle is not called. How can I find the login prompt?

The fact that the buffer is based on bytes and not lines, also explains why strncmp( "login:", buf, 6) did not work for me. The buffer reading does not necessarily Âstart with "login:".

Hope that explains, :-)
-Ãystein