Several wsa* of WinSocket
- typedef struct WSADATA {
- WORD wversion;
- WORD whighversion;
- #ifdef _win64
- unsigned short imaxsockets;
- unsigned short IMAXUDPDG;
- char FAR * LPVENDORINFO;
- Char szdescription[wsadescription_len+1];
- Char szsystemstatus[wsasys_status_len+1];
- #else
- Char szdescription[wsadescription_len+1];
- Char szsystemstatus[wsasys_status_len+1];
- unsigned short imaxsockets;
- unsigned short IMAXUDPDG;
- char FAR * LPVENDORINFO;
- #endif
- } wsadata;
The WSADATA structure is used to store the Windows Sockets initialization information that is returned by calling the AfxSocketInit global function.
1, WSAStartup
Usage:
Wsadata WsaD;
WSAStartup (Makeword (2,2), &wsad);
When an application calls the WSAStartup function, the operating system searches for the appropriate socket library based on the requested socket version, and then binds the found socket library into the application. The application can then invoke the other socket functions in the requested socket library.
In fact, if the Windows Socket program does not add this sentence, the call to the socket () function is unsuccessful and returns 1.
2, WSACleanup
WSAStartup should be used in pairs with wsacleanup, the function of WSAStartup is to initialize Winsock Dll,wsacleanup to unbind the socket library and release the system resources occupied by the socket library.
Under Windows, the socket is implemented as a DLL. Inside the DLL maintains a counter, only the first call to WSAStartup to actually load the DLL, the subsequent call is simply to increase the counter, and the function of the WSACleanup function is just the opposite, each call to make the counter minus 1, when the counter is reduced to 0 o'clock, DLL is unloaded from memory! So how many times you call WSAStartup, the WSACleanup should be called the corresponding number of times.
3, WSAGetLastError ()
Refers to the function that returns the last network error that occurred.
Cond......
Reference URL:
http://blog.csdn.net/bolike/article/details/7584727
http://www.bkjia.com/PHPjc/1067478.html www.bkjia.com true http://www.bkjia.com/PHPjc/1067478.html techarticle WinSocket a few wsa* typedef struct WSADATA {WORD wversion; WORD whighversion; #ifdef _win64 unsigned short imaxsockets; unsigned short IMAXUDPDG; char FAR * LPVENDORINFO; Char ...