Home > other >  Questions about the WsaAsyncselect model line up to send multiple files, now my logic is confusion,
Questions about the WsaAsyncselect model line up to send multiple files, now my logic is confusion,

Time:10-13

Is the first time I use TCP, know the basic concept, now stuck in the asynchronous send issue:
I registered in program using WSAAsyncSelect FD_READ | FD_WRITE | FD_CLOSE events, then, suppose I have 2 (or 20) 30 m file to line up to send to the same client (now don't consider the client how to receive, only considered sending problem), assuming that pseudo code is:
Mysend (file1);//Mysend will call my own packaging TcpServers class to send
Mysend (file2);

When sending the file, the file size is more than the web cache, then the send command will send some bytes after return WSAEWOULDBLOCK, and later the system will be delivered to the message queue FD_WRITE, assuming that the FD_WRITE will arrive after 1 second,

However, due to the send back, this time Mysend (file2) performed, Mysend (file2) also called send (), luckily, web cache can use this time, it is sent, so, just muddle up?

If in Mysend (file1); And Mysend (file2) in the event object is also not line, because it wasn't a multithreaded, the program will stop,
If all send behavior must be in response to a FD_WRITE events happen, that isn't my program has enabled FD_WRITH heavier? Program is very busy?

Hope get answer, thank you.
  • Related