I'm trying to learn libevent/libev (in this case its libev) from the following link: http://www.ibm.com/developerworks/aix/library/au-libev/
I'm wondering how to find out what the remote ip address is so I can build my own DHT.
I'm guessing it has something to do with the incoming structure but I just don't know.
Here is the callback code that the incoming variable is used, for the rest of the code click the link above.
void buf_read_callback(struct bufferevent *incoming,
void *arg)
{
struct evbuffer *evreturn;
char *req;
req = evbuffer_readline(incoming->input);
if (req == NULL)
return;
evreturn = evbuffer_new();
evbuffer_add_printf(evreturn,"You said %s\n",req);
bufferevent_write_buffer(incoming,evreturn);
evbuffer_free(evreturn);
free(req);
}
Basically the example code provides a "server" driven by libev events, you can connect to the server by telneting the server ip:port pair and it will just echo back everything you say to it -- Notice the line that says "You said %s\n"