calling select on udp socket returns 0 after receiving amount of data

869 views
Skip to first unread message

twei

unread,
Aug 13, 2014, 8:30:54 PM8/13/14
to native-cli...@googlegroups.com
Hi,
I'm porting a native client that streams video.
The client receives video frames via udp, process them, and then display to the screen.

I encountered an issue where after receiving the first few seconds of the video frames, the select function on the socket starts to return 0 (meaning no data is available to read).
However, the tcpdump does show that the server is actually sending data.

Is there a cap on how much data chrome can receive for a given time period?
Any recommendation on how to debug issue like this. Chrome's console log doesn't seem to be very useful.

Thanks for the help.


this is the code that checks if  there is data available to read (this is on mac, using glibc):

bool wait_for_action( unsigned timeout_millis ) {
      socket_type select_fd = m_socket;

        int            rdy;
       fd_set         wakeup;
      struct timeval timeout;

        FD_ZERO( &wakeup );
       FD_SET( select_fd, &wakeup );

        timeout.tv_sec  =  timeout_millis / 1000;
      timeout.tv_usec = (timeout_millis % 1000) * 1000;

        int ndfs = select_fd + 1;
             
        if( (rdy = select( ndfs, &wakeup, 0, 0, &timeout )) == c_socket_error )
       {
              throw exception( "select failed. (%d)", get_errorno() );
       }
      return (rdy == 0) ? false : true;  // rdy becomes 0 after a few frames
}

Ben Smith

unread,
Aug 14, 2014, 2:36:05 PM8/14/14
to native-cli...@googlegroups.com
Hi Twei,

Can you make a minimal example that exhibits this behavior? That will help us debug this issue.

Thanks!

twei

unread,
Aug 18, 2014, 6:28:24 PM8/18/14
to native-cli...@googlegroups.com
Hi,
Thanks.
I'm kinda struggled to create an example that can repro this issue.

The server is completed, but my client is getting -1 as the return value when calling recvfrom (errno is 38, i think it's ENOSYS).

any idea why recvfrom returns such result?  (note, in this sample app, select and bind seem to work, and I do call nacl_io_init_ppapi).
core.cc

twei

unread,
Sep 8, 2014, 5:09:06 PM9/8/14
to native-cli...@googlegroups.com
Got this figured out:

1. select turns 0:
This is caused by the sending thread working too fast and clots the pipe.
Adding a sleep for few milliseconds solved the issue.

2. recvform returns -1 and errno is 38:
library link order. make sure nacl_io is before pthread, ppapi...etc
Reply all
Reply to author
Forward
0 new messages