Re: [sigc] Socket library using libsigc++?
- From: Aaron Griffin <aaronmgriffin gmail com>
- To: libsigc-list gnome org
- Subject: Re: [sigc] Socket library using libsigc++?
- Date: Wed, 3 Aug 2005 13:58:08 -0500
Hmmm if you're interested in doing it youself, you can make something
like so (assuming it has access to the socket file descriptors):
NOTE: this may not work... I haven't tested it - it's just an example
to show you how easy it is to detect these things.
fd_set socks;
MyClientSocket cl("http://www.google.com",8080);
MyServerSocket srv(1234);
FD_ZERO(socks);
FD_SET(cl.descriptor(),socks);
FD_SET(srv.descriptor(),socks);
timeval tv;
tv.tv_sec = 1;
tv.tv_usec = 0;
int i = select(FD_SETSIZE,&socks,0,0,&tv);
if(i == 0) {} // timeout occured (1sec)
else if(i > 0) // i sockets are readable
{
//client readable indicates incoming data
if(FD_ISSET(cl.descriptor(),socks)) { /*emit*/ }
//server readable indicates incoming connection
if(FD_ISSET(srv.descriptor(),socks)) { /*emit*/ }
}
else { /*error*/ }
On 8/3/05, Ian Remmler <ian remmler org> wrote:
> Hi,
>
> QT has a thing called a QtSocketNotifier which allows
> asynchronous socket handling via QT's signals and slots. I
> prefer gtkmm, and of course libsigc++, so I was wondering if
> there is something that provides similay functionality using
> those libraries rather than QT? Basically I'm looking for
> something that will watch a socket and fire off a signal when
> there is something to do (e.g. there is new data to read).
>
> Thanks,
> - Ian.
>
> --
> "Just for the record, my main man is, and has been since 1987,
> Van Mundegaarde. And don't you forget it!" -- Strong Bad
> _______________________________________________
> libsigc-list mailing list
> libsigc-list gnome org
> http://mail.gnome.org/mailman/listinfo/libsigc-list
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]