Issue with reading data on socket
sai koushik
saikoushik539 at gmail.com
Thu Oct 13 08:50:15 CEST 2011
Hi ,
I tried to add loop still no success.
added :
ev_loop(EV_A_ 0);
is it possible to read data asynchronously on socket using any type of
watcher functions .
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.
Thanks,
Sai.
On Thu, Oct 13, 2011 at 11:56 AM, Harm van Tilborg <list at zeroxcool.net>wrote:
> Hi Sai,
>
> You will need to run ev_loop after you've set everything up. That is
> right after you call ev_io_start.
>
> --
> Harm
>
> On Thu, Oct 13, 2011 at 08:12, sai koushik <saikoushik539 at gmail.com>
> wrote:
> > Hi ,
> > i tried to crate a socket client using libev , and this client has to
> > listen for data from the server.
> > and i tried as below
> > ev_io stdin_watcher;
> > ....
> > sock_fd = socket(PF_UNIX, SOCK_STREAM, 0);
> > memset(&addr, 0, sizeof(addr));
> > addr.sun_family = AF_UNIX;
> > strcpy(addr.sun_path, ifname);
> > err = connect(sock_fd, (struct sockaddr *) &addr, sizeof(addr));
> > int flags=0;
> > fcntl(sock_fd, F_SETFL, flags | O_NONBLOCK);
> > ev_io_init(&stdin_watcher,stdin_cb, sock_fd, EV_READ);
> > ev_io_start (EV_DEFAULT_UC_ &stdin_watcher);
> > ....
> > and callback is
> > static void stdin_cb (EV_P_ ev_io *w, int revents)
> > {
> > printf("\n callback \n");
> > }
> >
> > issue is when i tried to run client program callback is getting invoked
> > forever and it is going into infinte loop.
> > i didn`t used ev_loop.
> > Is above code is in proper way of reading data from from server?
> > any help?
> > Thanks
> >
> > _______________________________________________
> > libev mailing list
> > libev at lists.schmorp.de
> > http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20111013/9fcf6fb4/attachment.html>
More information about the libev
mailing list