Hi,
I want to test the performance of server/client arhitecture that I wrote but I have problems with non-blocking sockets. When I use fcntl I can not run client and server to work at the same time. While I run server client has already sent 5000 replies back although the server is not start to stream. How
can I make difference on client when server isn't turned on and when packet is lost? In my code client
behaves same.
On the other side, when I don't use fcntl then If I client doesn't receive packet
it blocks and wait on that packet, he even don't sent a reply back. I want that
client send back reply and to continue to receiving packets.
I dont want to use sleep because I need real time performance.
I'm wondering how real application are working, what is trick to implement this?
Thx
server
Code:
fcntl(socket,F_SETFL,O_NONBLOCK);
while(1){
sendto clients
pthread_create(reply_processing)
}
reply_processing(){
recvfrom_clients
}
client
Code:
fcntl(sd,F_SETFL,O_NONBLOCK);
while(1){
bytes = recvfrom server, buf
if(nbytes != -1){
if(buf > = 512) write
else EOF return 1;
}else{
lost++
nack sent
}
}