Issue with reading data on socket

Jonathan Neuschäfer j.neuschaefer at
Thu Oct 13 18:22:26 CEST 2011

On Thu, Oct 13, 2011 at 12:20:15PM +0530, sai koushik wrote:
> Hi ,
>       I tried to add loop still no success.
> added :
>        ev_loop(EV_A_ 0);

EV_A_ only works in a function, which has EV_P as the first parameter.
It seems you've put the ev_loop() call into your callback, which likely
won't do what you think.

You should call ev_loop after ev_io_start, i.e. in your socket setup
function or in main.

> is it possible to read data asynchronously on socket using any type of
> watcher functions .

The watcher functions only set up callbacks which are called whenever
data is ready, you still read with read() or recv().

You can only watch the state of a socket with ev_io watchers, not with
other watcher types.

> can u point me some socket client examples in libev, i
> checked libev-examples module in git but it is not matching for my use-case.
looks like a client to me. If it doesn't help, what are you trying to

	Jonathan Neuschäfer

More information about the libev mailing list