View Single Post
Old Mar 17th, 2006, 10:24 AM   #2
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
The read does not appear to be a non-blocking read on the socket - ie., it sits there and waits forever which explains why more than one client fails.

This will make the socket you are reading on non-blocking (POSIX code)
#include <fcntl.h>
/* fd = socket id */
int setNonblocking(int fd)                                                     
{                                                                              
    int flags;                                                                 
                                                                               
    if ((flags = fcntl(fd, F_GETFL, 0)) == (-1)    )                             
    {
        flags = 0;                                                             
    }
    return fcntl(fd, F_SETFL, flags | O_NONBLOCK);                             
                                              
}
I would suggest reading at least chapter 5:

http://www.advancedlinuxprogramming.com/alp-folder

The ipc stuff is the same linux or not - it's all POSIX
jim mcnamara is offline   Reply With Quote