LPSTR CUDP::GetMac()
{
IPX_ADDRESS_DATA adapter_data;
adapter_data.adapternum = 0;
int optlen = sizeof(IPX_ADDRESS_DATA);
if(SOCKET_ERROR==getsockopt(m_sock,NSPROTO_IPX,IPX_ADDRESS,(char*)&adapter_data,&optlen))
{
return NULL;
}
memcpy(mac,adapter_data.nodenum,6);
return mac;
}
这个是干什么的?特别是getsockopt()和他的参数是什么意思??谁能帮我改成另外一种和这个功能一样的程序呀??谢谢了!

解决方案 »

  1.   

    The getsockopt function retrieves a socket option.int getsockopt(
      SOCKET s,
      int level,
      int optname,
      char* optval,
      int* optlen
    );Parameters

    [in] Descriptor identifying a socket. 
    level 
    [in] Level at which the option is defined; the supported levels include SOL_SOCKET and IPPROTO_TCP. See Windows Sockets 2 Protocol-Specific Annex for more information on protocol-specific levels. 
    optname 
    [in] Socket option for which the value is to be retrieved. 
    optval 
    [out] Pointer to the buffer in which the value for the requested option is to be returned. 
    optlen 
    [in, out] Pointer to the size of the optval buffer, in bytes. 参考MSDN
      

  2.   

    好像是取MAC地址的。 getsockopt你查msdn好了。
      

  3.   

    嗯,建议遇到类似情况,先到MSDN查一下。
    http://msdn.microsoft.com/
      

  4.   

    This function retrieves a socket option.