When you create a socket it is automatically set to be blocking. If you want to set it to non blocking then you can call fcntl, i.e.

Code:
fcntl(sockfd, F_SETFL, O_NONBLOCK);
however this is something i dont recommend doing as it requires you to continually check the socket and can kill the CPU.

I highly recommend you use the select method which can monitor a set of sockets and when there is an event on one of them you can then determine which one it is and work with it. You can also add a timeout interval on select so if no event is received on the sockets during that time interval then it carries on with program execution.

Let us know if you need any help using select. It is relatively easy.

Hope this helps