WSAIoctl
The Windows Sockets WSAIoctl function controls the mode of a socket.int WSAIoctl (
  SOCKET s,                                               
  DWORD dwIoControlCode,                                  
  LPVOID lpvInBuffer,                                     
  DWORD cbInBuffer,                                       
  LPVOID lpvOUTBuffer,                                    
  DWORD cbOUTBuffer,                                      
  LPDWORD lpcbBytesReturned,                              
  LPWSAOVERLAPPED lpOverlapped,                           
  LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionROUTINE  
);
 
Parameters

[in] A descriptor identifying a socket. 
dwIoControlCode 
[in] The control code of operation to perform. 
lpvInBuffer 
[in] A pointer to the input buffer. 
cbInBuffer 
[in] A number indicating the size of the input buffer. 
lpvOutBuffer 
[out] A pointer to the output buffer. 
cbOutBuffer 
[in] A number indicating the size of the output buffer. 
lpcbBytesReturned 
[out] A pointer to actual number of bytes of output. 
lpOverlapped 
[in] A pointer to a WSAOVERLAPPED structure (ignored for non-overlapped sockets). 
lpCompletionRoutine 
[in] A pointer to the completion routine called when the operation has been completed (ignored for non-overlapped sockets). 

解决方案 »

  1.   

    to  public(丐帮(二袋)弟子) :
        
             3q,不知能否列举一下参数dwIoControlCode的取值及其具体含义?
    另外,这个函数是不是只能在win2000下使用?
      

  2.   

    WSAIoctl()
    简述:控制一个套接口的模式。          #include <winsock2.h>          int WSAAPI WSAIoctl(SOCKET s, DWORD
              dwIoControlCode, LPVOID lpvInBuffer, DWORD
              cbInBuffer, LPVOID lpvOutBuffer, DWORD
              cbOutBuffer, LPDWORD lpcbBytesReturned,
              LPWSAOVERLAPPED lpOverlapped,
              LPWSAOVERLAPPED_COMPLETION_ROUTINE
              lpCompletionRoutine);s:一个套接口的句柄。
    dwIoControlCode:将进行的操作的控制代码。
    lpvInBuffer:输入缓冲区的地址。
    cbInBuffer:输入缓冲区的大小。
    lpvOutBuffer:输出缓冲区的地址。
    cbOutBuffer:输出缓冲区的大小。
    lpcbBytesReturned:输出实际字节数的地址。
    lpOverlapped:WSAOVERLAPPED结构的地址。
    lpCompletionRoutine:一个指向操作结束后调用的例程指针。返回值:
    调用成功后,WSAIoctl ()函数返回0。否则的话,将返回INVALID_SOCKET错误,应用程序可通过WSAGetLastError()来获取相应的错误代码。错误代码:
    WSANOTINITIALISED 在调用本API之前应成功调用WSAStartup()。
    WSAENETDOWN 网络子系统失效。
    WSAEINVAL cmd不是一个合法的命令;或者一个输入参数非法;或者命令对于该种类型的套接口不适用。
    WSAEINPROGRESS 在一个回调函数运行时调用了该函数。
    WSAENOTSOCK 描述字不是一个套接口。
    WSAEOPNOTSUPP 指定的ioctl命令无法实现,例如在SIO_SET_QOS或                              SIO_SET_GROUP_QOS中指定的流描述无法实现。
    WSA_IO_PENDING 一个重叠操作被成功启动,过后将报告完成情况。
    WSAEWOULDBLOCK 套接口标志为非阻塞,且所需操作将产生阻塞。