hi all :)
Im having trouble with this error (WSAEWOULDBLOCK). It would be better if I start with the code which is:
Ive got a loop (its not really loop, but it is called every 1 milisecond) with two functions in it:
1 2
|
accept_connections();
receive_data();
|
accept connections isnt important here so Ill post a part of receivedata func()
1 2 3 4 5 6
|
for ( int i = 0; i < clients.size() && !clients[i].disconnecting; i++ ){
if ( receive_client ( &clients[i], buffer, BUFSIZE ) ){
if(buffer[1]==SIGN_COORDS) { clients[i].setCoords(buffer); send_all(); }
...
}
}
|
the problem is in function send_all():
1 2 3 4 5 6 7 8 9
|
for(int current=0; current<clients.size(); current++){
for(int in=0; in<clients.size(); in++){
if(in != current){
char msg[BUFSIZE];
....
send_data(&clients[current], msg, BUFSIZE);
}
}
}
|
send_data() is just a function which sends msg to client whith size of BUFSIZE and handle errors and thats how I get the error WSAEWOULDBLOCK.
so how it works:
when the server receive a message that some player (client) has moved (changed its location) the server sends location of all players to all players through send_all() func. But after a time of running (about few seconds, 10-20) I get this error when sending data to some client and after a while again for another client until they are all disconnected.
The problem is that when I get this error I can send() messages to that client no more, but I dont know why when in the docs is written that it is non fatal error and also why it is running a while and then it starts with these errors... Also the client and the server both are non blocking
thanks for every reply :)