LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Event Driven Sockets (https://www.linuxquestions.org/questions/programming-9/event-driven-sockets-486064/)

kar_the_terrible 09-22-2006 02:21 PM

Event Driven Sockets
 
Im trying to write code in Linux for event drive socket communication. My preference is to use PF_UNIX sockets, here is a forum post that has some sample code,

<snip-link> uwsg.iu.edu/hypermail/linux/net/9806.0/0189.html <snip-link>

I compiled it as is, but it does not work as expected (read Orig. Poster's comment), in that I only get one SIGIO/SIGPOLL interrupt (I believe those two signal codes are identical), I can only read the first message sent by the client, after which no further SIGIO interrupts occur even though the client keeps sending a message every second.

The following was done:
1) I thought that maybe the client was buffering data till some threshold was reached. But even after explicitly flushing the sock-fd, I did not get an interrupt on the server end.

2) Could the server-side socket be buffering data?

3) Should the SIGIO interrupt handler be associated with the listening socket on the server-side or the socket used in the 'accept' system call?

4) Is there a library out there that you prefer? Other than QT etc. my target app is for an embedded sys with extremely limited resources, so I'd prefer a plain vanilla C/C++ library.

Thanks.

Aeiri 09-23-2006 11:41 AM

It's my understanding that a recv() on a socket should "block" (or just sit there) until enough data is received by the socket. So, if you just execute a recv() of 1 after you clear the buffer, it will wait until data is received.

kar_the_terrible 09-23-2006 02:29 PM

Is that true even if the socket is set as nonblocking? or does that apply to only read() and write() ?

Aeiri 09-23-2006 04:41 PM

If the socket is set as nonblocking that isn't true.


All times are GMT -5. The time now is 12:17 AM.