Finally, I finally found out why the first wsarecv shipping failed on the port was completed!
The prototype of wsarecv in msdn is as follows:
Int wsarecv (
Socket s,
Lpwsabuf lpbuffers,
DWORD dwbuffercount,
Lpdword lpnumberofbytesrecvd,
Lpdword lpflags,
Lpwsaoverlapped lpoverlapped, lpwsaoverlapped_completion_routine lpcompletionroutine );
The socket, buffer, and overlapped structures are available. The final value can be set to null. Only numberofbytesrecved and flags are declared and passed in. However, there is a easily missed point, that is, the pointer to the 5th flags parameter. Before passing in, you must initialize the flags value to 0. I finally sawCode, My is almost the same as that, but the one that can normally receive data, but I always have a 10045 error, one by one to check the comparison code and find the only thing that has an impact, it is the one with flags = 0, but none of them. I will immediately go to the description on msdn. I think it is of the [In, out] type. After it is added, it is also normal. Alas, I searched a lot of online materials, but I didn't find any direct answers. But now we can breathe a sigh of relief. The problem is discovered only in practice !!