name: Sumit Jaiswal
problem : Nonbloacking socket in C , under chat server;

Hi,

Chat server in C language:

Problem:
when i try to connect more then two client my program
get hangs i think its a problem of socket blocking please help me to
make non blocking socket

i use fcntl() function for nonblocking socket like-
=======================================
struct sockaddr_in SerAddr, CliAddr;
int b; // for bind
int optval = 1;
int sockfd;
int fileflags;

sockfd = socket(AF_INET, SOCK_STREAM, 0);
if(sockfd < 0)
{
perror("Socket");
exit(-1);
}
setsockopt(sockfd,SOCK_STREAM,SO_REUSEADDR,(char *)&optval,
sizeof(optval));

fcntl(sockfd,F_SETFL,O_NONBLOCK);

if (fileflags = fcntl(sockfd, F_GETFL, 0) == -1)
{
perror("fcntl F_GETFL");
exit(1);
}

if (fcntl(sockfd, F_SETFL, fileflags | FNDELAY) == -1)
{
perror("fcntl F_SETFL, FNDELAY");
exit(1);
}

====================================

this is not working .... please help me to make nonbolcking socket of
give me some idea .
if possible then please send me a general program to understand

Thank you.