Sending while recieving in C

Posted by Spidfire on Stack Overflow See other posts from Stack Overflow or by Spidfire
Published on 2010-05-31T10:52:39Z Indexed on 2010/05/31 10:52 UTC
Read the original article Hit count: 197

Filed under:
|
|
|

Ive made a piece of code in whats on my server, the problem is that it doesnt send while im recieving? so if i send something to client 1 to client 2, client2 only recieves if he sends something himself.. how can i solve this ?

 /* Thread*/
while (! stop_received) {
        nr_bytes_recv = recv(s, buffer, BUFFSIZE, 0);

        if(strncmp(buffer, "SEND", 4) == 0) {
            char *message = "Text asads \n";
            rv = send(users[0].s, message, strlen(message), 0);
            rv = send(users[1].s, message, strlen(message), 0);
            if (rv < 0) {
                perror("Error sending");
                exit(EXIT_FAILURE);
            }           
        }else{
            char *message = "Unknown command \n";
            rv = send(s, message, strlen(message), 0);
            if (rv < 0) {
                perror("Error sending");
                exit(EXIT_FAILURE);
            }
        }
}

© Stack Overflow or respective owner

Related posts about c

    Related posts about socket