I am working on socket programming. I am using asynchronous socket APIs to send and receive.
When I have WSARecv and WSASend functions in the same function, the data gets transferred properly; whereas if i separate send and receive functions, while sending the data I am getting error 10054 (connection reset by peer).
The _send_data() function has 2 parameters, the data and the socket where to send the data.
Can anyone tell me the reason why this is happening ?
can you please explain how can i go with that ?
Right now I am using select() function to check the status of the socket, whether it is ready to write or not. Is there any other mechanism by which I will get the status of the socket.
Basically I am write a client server application which plays a video file in Media player. It receives a request from browser. After receiving that request, the socket I get is from the media player and I write the data to this socket.
How this new socket connection from media player affects the data transfer using async operations ?
Forget the code for now. Write down two columns, one for the server and the other for a client. Then write what message is sent first, what's send next and so on until they're done.
That is your protocol. There should be a clear initialisation sequence and a clear termination sequence. When you don't do that, it all goes bad and one party terminates the conversation while the other isn't expecting it.
It's sort of like you going to a Bank to deal with a cashier about making a deposit. And just before you hand over your the money, the cashier closes the desk and goes for lunch, leaving you standing there. That's what's happening in your program.