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

[Libevent-users] Bind outgoing IP with bufferevents



Hello,

I want to bind an outgoing IP to a 'bufferevent socket' with libevent 2.0.3-alpha, how would I do this? I'm currently using the following (trimmed down) snippet of code to connect to a remote host:

event = bufferevent_socket_new(client->base, -1, BEV_OPT_CLOSE_ON_FREE);
bufferevent_socket_connect(event, (struct sockaddr *)&sockaddr, sizeof(sockaddr));

Normally I'd just call bind() on the fd. But this time libevent creates the socket for me.

Calling bufferevent_getfd(event) returns -1, which seems to be the same FD that was passed to _socket_new, but isn't usable at all.

Am I missing some function that allows me to do this? Should I create a socket manually, bind it to the outgoing IP and then feed it to bufferevent, if so what is the best way to do this?

Any help is appreciated.

Cheers,
Bas Verhoeven
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.