making nonblocking socket - VMS

This is a discussion on making nonblocking socket - VMS ; Sumit Jaiswal 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 ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: making nonblocking socket

  1. making nonblocking socket

    Sumit Jaiswal
    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.

  2. Re: making nonblocking socket

    Tinku,

    I miss the link to VMS! Do you think this is the right newsgroup?

    e.

    Tinku schreef:
    > Sumit Jaiswal
    > 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.


  3. Re: making nonblocking socket

    OOh thanks to inform me that its not a C language Group ... ya its was
    my mistake Thanks again

+ Reply to Thread