OT: Socket IO disconnect



Sorry for the off topic post but maybe someone can point me to the correct
resource :).

I have a gui (gtk 2.6) that monitors and displays data values in memory. The
gui is not fast enough to capture all the data so instead it spawns a data
capture thread (no gui manipulation is done here), opens and binds to a unix
domain datagram socket and blocks on read() waiting for a timing signal that
synchronizes the data capture with the data generation. The provider of the
data connects to the same unix socket and writes the frame number [0-59].
When the data capture thread reads in frame number 0 it jumps into a while
loop that begins the data capture keeping track of the frame numbers and any
dropped frames.

The basic while loop looks something like this:

capturedata = TRUE;
while(capturedata == TURE)
{
   //block until new frame comes in.
   read(socket...);
   if(insynch == TRUE)
   {
      list = LISTHEAD;
      while(list != NULL)
      {
         capture_data(list->variable);
         list = list->next;
      }
   }
}

LISTHEAD holds a linked list of data variables ready for capture, so in each
frame the inner while loop captures data for all values in the list.
Elements can be added and removed from the list without interfering with the
capture process.

The problem I am having is that when I remove all items from the linked list
and then add more some time after (this is the frustrating part) the socket
will get removed (as if calling unlink() on the socket file) and the read()
call will emit a bunch of errors , but there is no code to remove the socket
file inside the while loop. I read somewhere that if the process stops
comunicating with the socket that the socket will close, but I'm unclear as
why this might be the case if the capturedata variable is always true and we
keep reading from the socket even when LISTHEAD == NULL (no variables in
list).

If anyone has any suggestions on where to take this issue to I'd really
appreciate it, I'm running out of ideas :).

Thanks!

-M




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]