Failed to finish the first wsarecv shipping on the port

Source: Internet
Author: User

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 !!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.