WSAStartup

来源:互联网 发布:股票编程接口 编辑:程序博客网 时间:2024/04/28 09:39

WSAStartup】  初始化套接字

#include<windows.h>
#pragma    comment(lib,"ws2_32.lib")

 

int WSAStartup(

  _In_   WORD wVersionRequested,

  _Out_  LPWSADATA lpWSAData

);

_In_   WORD wVersionRequested  //要使用的socket api的版本

 _Out_  LPWSADATA lpWSAData //用来保存返回结果的指标

 

【返回值】

If successful, the WSAStartup function returns zero. Otherwise, it returns one of the error codes listed below.

The WSAStartup function directly returns the extended error code in the return value for this function. A call to the WSAGetLastError function is not needed and should not be used.

Error code

Meaning

WSASYSNOTREADY

The underlying network subsystem is not ready for network communication.

WSAVERNOTSUPPORTED

The version of Windows Sockets support requested is not provided by this particular Windows Sockets implementation.

WSAEINPROGRESS

A blocking Windows Sockets 1.1 operation is in progress.

WSAEPROCLIM

A limit on the number of tasks supported by the Windows Sockets implementation has been reached.

WSAEFAULT

The lpWSAData parameter is not a valid pointer.

 

WORD  分配和 (可选) 初始化一个单词 (2 字节) 的每 initializer的存储。 ,因为类型说明符任何位置类型是非法的,也可以使用。

 wVersionRequested [in]

最高版本的Windows Sockets规范,调用者可以使用。高位字节指定副版本号;低位字节指定的主版本号。

 

//初始化套接字

WORD wVersionRequested;

WSADATA WSAData;

wVersionRequested=MAKEWORD(1,1);

WSAStartup(wVersionRequested,&WSAData)

0 0