/ *
Description:
1 This article is to look at the beginners like me. If you have some experience, please don't look, because it will cost your precious time.
2 Using MSDN versions: MSDN Library - October 2001
* /
I wrote this place for the first time, I feel very fresh.
I also hope that this thing (write documentation) is good for me and everyone.
Because some curve occurred during the development process, then discovered. I want to remind everyone to pay attention.
Just started to contact Winsock programming is 2002-11-30, bought "Visual C 6.0 Network Programming Practice Tutorial" This book (I personally think this is a very good Winsock programming book, she is very suitable for beginners) ,
When you start using Winsock, you are using CasyncSocket. When Send and RecVive, NFLAGS has default value 0, so it is not attached.
/ * CasyncSocket :: Send
Virtual Int Send (const void * lpbuf, int nbufflen, int nflags = 0);
CasyncSocket :: Receive
Virtual int REIVE (Void * LPBUF, INT NBUFLEN, INT NFLAGS = 0);
* /
And it is more difficult to use, there is no big problem.
In the late period, because I want to try different things, I want to use my own CMYSocket class, package the Winsock API, (I have always liked myself to pack the next layer, I feel better).
The problem is coming, in the process of packaging, I view MSDN
/ *
int send (SOCKET s, const char FAR * buf, int len, int flags);. The flags parameter can be used to influence the behavior of the function beyond the options specified for the associated socket The semantics of this function are determined by the Socket Options and the flags parameter. The latter is constructed by OR-INGTE FOLLOWING VALUES:
Value meaning msg_dontrol. A Windows Sockets Service Provider Can Choose To Ignore This flag.
MSG_OOB Send-of-of-Band Data (Stream-Style Socket Such As Sock_Stream Only. Also See Decnet Out-of-Band Data for a Discussion of this Topic).
* /
/ * I personally translated:
The Flags parameter can affect the behavior of the remote socket associated with (local socket), the socket option, and the Flags parameter determine the functionality of this function (Send function). The latter (Flags parameter) can be or (|). The meaning of the value msg_dontroute indicates that the data sent should not pass through Routing, Windows Socket Service Provider can choose to ignore this flag
("Windows Network Programming Technology" P141 is said to: the MSG_DONTROUTE flag requires the transfer layer not to put it out of the packet, and the transfer of the base layer determines whether to implement this request)
Msg_oob Sends OOB DATA (such as a streaming socket, only Sock_Stream applicable, you can also see the discussion of this theme of Out-of-Band Data)
* /
At Send, I chose the msg_dontroute flag because I didn't have external data, (I thought I could only have such a value to fill in!)
At the RECV, I chose MSG_PEEK.
As a result, I didn't get the correct result when I was in Recv, and I still don't know why I am wrong.
I checked a morning, haha, finally knew that it was a logo setting problem.
I am set to 0 now. Work is very good.
Do you have this problem? Let's take a wake up an initiator like me.