做了客户端,服务端的程序,在同台机器上运行时均正常,但是分别放在2台机器时出现WSA错误码11004,该如何解决?客户端部分代码如下: int ret;
SOCKET so_fd;
struct sockaddr_in l_addr_in;
struct in_addr l_addrhost;
LPHOSTENT targethost;
CString strTemp;
_bstr_t bstrTemp;//解析地址
memset(&l_addrhost, 0x00, sizeof(l_addrhost));//清0
l_addrhost.s_addr = inet_addr(strHost);//把一个Internet标准的"."记号地址转换成Internet地址数值


if (l_addrhost.s_addr == INADDR_NONE)//传入的字符串不是一个合法的Internet地址
{
targethost = gethostbyname(strHost);//从服务器主机名得到对应的名字(有可能多个)和地址
}
else{
targethost = gethostbyaddr((const char *)&l_addrhost,sizeof(l_addrhost), AF_INET);//从网络地址得到对应的服务器名字(有可能多个)和地址
}

if(targethost == NULL)
{
long nRetCode=WSAGetLastError();
strTemp.Format("无法解释的服务器主机名! [WSA错误代码:%d]",nRetCode);
bstrTemp=strTemp;
g_pLogout->LogoutErrorInfo(nRetCode,bstrTemp);
return RET_UNSUCCESS;
}
//创建客户端TCP连接套接字
so_fd = socket(AF_INET, SOCK_STREAM, 0);
if( so_fd == INVALID_SOCKET )
{
long nRetCode=WSAGetLastError();
strTemp.Format("创建客户端TCP连接套接字失败! [WSA错误代码:%d]",nRetCode);
bstrTemp=strTemp;
g_pLogout->LogoutErrorInfo(nRetCode,bstrTemp);

return RET_UNSUCCESS;
}
//非阻塞设置     
u_long l_arg = 1L;//非阻模式,0则为阻塞模式
ret = ioctlsocket(so_fd, FIONBIO, &l_arg);//非阻塞设置5.1.12 ioctlsocket()
if(ret == SOCKET_ERROR)
{
long nRetCode=WSAGetLastError();
strTemp.Format("套接字:%d非阻塞设置失败! [WSA错误代码:%d]",so_fd,nRetCode);
bstrTemp=strTemp;
g_pLogout->LogoutErrorInfo(nRetCode,bstrTemp);

SocketClose(FALSE,so_fd);
return RET_UNSUCCESS;
}//连接服务器
l_addr_in.sin_family = AF_INET;
l_addr_in.sin_port   = htons(nPort);
l_addr_in.sin_addr   = *((LPIN_ADDR)*targethost->h_addr_list);
ret = connect(so_fd, (LPSOCKADDR)&l_addr_in,sizeof(l_addr_in));......
......
......

解决方案 »

  1.   

    1.WSANO_DATA (11004) Valid name, no data record of requested type. The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for. The usual example for this is a hostname -> address translation attempt (using gethostbyname or WSAAsyncGetHostByName) which uses the DNS (Domain Name Server), and an MX record is returned but no A record - indicating the host itself exists, but is not directly reachable.2.
    SYMPTOMS
    Under certain conditions, when a projects destination server is identified by IP address instead of a DNS name, and CRS is unable to find the IP address, CRS will abort the project at the start of the session and report a Winsock error of 11004 in the Windows NT event log. RESOLUTION
    This is a bug in the release version of MCIS 1.0. The problem is in Crsdll.dll, which has been updated in SP1 for Microsoft Commercial Internet System version 1.0. To correct this problem, install SP1 for MCIS v1.0 on the server(s). This will update Crsdll.dll. 
      

  2.   

    Windows Sockets错误码  Berkeley 对应错误码  错误号  解释
    WSANO_DATA              NO_DATA             11004   同BSD
      

  3.   

    WSANO_DATA(11004) Valid name, no data record of requested type.请求的名字合法并且在数据库中找到了,但它没有正确的关联数据用于解析。此错误的通常例子是主机名到地址(使用gethostbyname()或WSAAsyncGetHostByName()函数)的DNS转换请求,返回了MX(Mail eXchanger)记录但是没有A(Address)记录,它指示主机本身是存在的,但是不能直接到达
      

  4.   

    MSDN上的我也看过了,但是我在输服务器的地址时是使用IP地址的,而且调式时也发现调用的是gethostbyaddr函数而不是gethostbyname,但是错误号依旧
      

  5.   

    而且,对于在客户端输入服务器地址127.0.0.1 或者192.168.0.188(本机网卡IP),220.184.132.52(本机上网ADSL的IP),如果客户,服务端程序在同台机器上运行时,均正常
      

  6.   

    还有如果我输入服务器地址是WWW.163.COM反而解析地址(gethostbyname)是正确的,
      

  7.   

    在微软的网站上找了半天没找到啊只有个这个Download details: Commercial Internet System (MCIS) 2.5 载下来不能安装http://search.microsoft.com/search/results.aspx?View=en-us&p=1&c=1&st=b&qu=mcis&na=33&cm=512