This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

About nonblocking I/O's socket programming

Other Parts Discussed in Thread: OMAPL138

Hi,

I use the device of omapl138. I use the NDK project to access UDP transmission, and I want to set the socket option to Non-blocking I/O mode. Because the NDK's default is

blocking I/O mode.

When I use the default mode, it seems that process is blocked by recvfrom() function if there is no data sent by the other device without function call of sendto().

May I use the setsockopt() function to set the SO_BLOCKING flag  to achieve this. Is there anyone used to it before?

Thanks,

Yuan

  • int sockblk;

    sockblk = 0;

    setsockopt(snd,SOL_SOCKET,SO_BLOCKING,&sockblk,sizeof(sockblk));  /* set socket to nonblocking */

    snd is the socket which I declare.

    I use the above code to set the socket non-block. And I work with the TI's NDK project. But the network doesn't build up after the setting.

    If I don't add the three lines to set non-blocking socket. The network can build up.

    Does anyone know how do I solve it?

    Thanks,

    Sincerely,

    Yuan