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

Re: [Libevent-users] strange exit with hand-made socket and bufferevent



Thanks Nick!

Yes, the last commit fixed the example. I was compiling it with g++
and that's probably why it worked.

As for my program, i fixed it by using
bufferevent_socket_connect_hostname instead of evdns_* calls.

Questions:
1. What happens if the dns resolver fails? Does it retry? Does it give
up? How do I know what happened?
2. What happened to EVUTIL_CHECK_FMT? It was useful. What can I replace it with.

I am/was using the latest git and ubuntu 9.10 with 2.6.31 kernel.

Thanks again!
Mihai


On Sat, Feb 20, 2010 at 8:16 PM, Nick Mathewson <nickm@xxxxxxxxxxxxx> wrote:
> On Tue, Feb 16, 2010 at 2:57 PM, Mihai Draghicioiu
> <mihai.draghicioiu@xxxxxxxxx> wrote:
>> Thanks Brian! Indeed, if I put the two lines that enable writing and
>> write to the bufferevent right in the connected callback, the darn
>> thing works fine!
>>
>> However, this was just a minimal example. I'd like it, however, if
>> libevent supported this by marking inside the bufferevent structure
>> that the socket fd is connected or isn't connected, and only write to
>> it when it has connected. I suspect libevent checks if the fd==-1, and
>> only then issues the connect(). if fd!=-1, it assumes it's connected.
>> So this would be simplified if libevent somehow knew about my fd, and
>> whether it's connected or not... There seems to be a getpeername()
>> function that might do the trick.
>
> Hm. ÂRight now, Libevent assumes that a socket is unconnected if you
> call bufferevent_socket_connect() on it. ÂThe problem seems to have
> been that bufferevent_socket_connect_hostname() didn't also suspend
> reading and writing until the hostname resolution was done. ÂI've
> checked in a fix as db08f640; does that work for you? ÂIt makes your
> original example work for me on Linux[1], but I haven't tried it on
> your longer program.
>
> [1] BTW, please remember to mention what version of Libevent, what
> operating system, and what language you're using. ÂThe original
> example code doesn't build for me in C (since you're casting to
> "event_base" instead of "struct event_base"), and works fine on OSX
> (by some weird OSX accident I didn't investigate).
>
> yrs,
> --
> Nick
> ***********************************************************************
> To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
> unsubscribe libevent-users  Âin the body.
>
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.