Guest_imported
New member
- Jan 1, 1970
- 0
I'm using a derivated class of CSocket to programm my apliccation. When I introduce the IP adrees there is nothing problem, but if it's the host name, like appears an error message as this, error GetHostByName #11001. Well, #11001 is error code returned by the method WSAGetLastError. My problem is that I don't get to know what's the meanning of this code, and consequently, what am I doing wrong?
COutDlg dlg(this);
CBlockingSocket internet;
CSockAddr saServer;
struct sockaddr_in local;
struct sockaddr_in remot;
PHOSTENT hp;
int s;
unsigned int ip;
s= socket (AF_INET, SOCK_DGRAM,0);
if (s==-1)
{
MessageBox("Error durant la creació del socket",NULL,MB_OK);
exit(1);
}
else
{
MessageBox("Socket Inicialitzat correctament",NULL,MB_OK);
}
UpdateData(TRUE);
dlg.m_name=m_host;
dlg.m_error=21;
dlg.DoModal();
saServer=internet.GetHostByName(m_host);
/* hp=gethostbyname(m_host);
if (hp==NULL)
{
dlg.m_error=WSAGetLastError();
dlg.DoModal();
ip=inet_addr(m_host);
if (ip ==-1)
{
MessageBox("Error en la introducció de l'adreça"
exit(1);
}
}
else memcpy(&ip, hp->h_addr, 4);
/* Estructura de l'adreca del servidor remot */
remot.sin_family = AF_INET;
remot.sin_port = htons(7321);
MessageBox("I'M here"
remot.sin_addr.s_addr = saServer.sin_addr.s_addr;
dlg.m_iphost=ip;
dlg.DoModal();
Thanks for all!
COutDlg dlg(this);
CBlockingSocket internet;
CSockAddr saServer;
struct sockaddr_in local;
struct sockaddr_in remot;
PHOSTENT hp;
int s;
unsigned int ip;
s= socket (AF_INET, SOCK_DGRAM,0);
if (s==-1)
{
MessageBox("Error durant la creació del socket",NULL,MB_OK);
exit(1);
}
else
{
MessageBox("Socket Inicialitzat correctament",NULL,MB_OK);
}
UpdateData(TRUE);
dlg.m_name=m_host;
dlg.m_error=21;
dlg.DoModal();
saServer=internet.GetHostByName(m_host);
/* hp=gethostbyname(m_host);
if (hp==NULL)
{
dlg.m_error=WSAGetLastError();
dlg.DoModal();
ip=inet_addr(m_host);
if (ip ==-1)
{
MessageBox("Error en la introducció de l'adreça"
exit(1);
}
}
else memcpy(&ip, hp->h_addr, 4);
/* Estructura de l'adreca del servidor remot */
remot.sin_family = AF_INET;
remot.sin_port = htons(7321);
MessageBox("I'M here"
remot.sin_addr.s_addr = saServer.sin_addr.s_addr;
dlg.m_iphost=ip;
dlg.DoModal();
Thanks for all!