Sending while receiving 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 11:02 UTC
Read the original article Hit count: 167

Filed under:
|
|
|

I've made a piece of code in what's on my server, the problem is that it doesn't send while im receiving. so if i send something to client 1 to client 2, client2 only receives 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