how to ensure the data is sent via a tcp socket before reading from it

Viewed 33

I write a simple client/server program in c/linux.

My client will send a short message to to server, then it calls recv(fd,...) immediately to read data from the same socket, but I found the the data is not sent to server, only I quit the client, then data is sent to server, I think it is because the socket is closed then data is sent

But after some search, find there is no way to flush socket , and TCP_NODELAY doesn't have the flush effect.

Is there a way to solve this ,currently I am using tcp socket .

0 Answers
Related