Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gethostbyaddr

Status
Not open for further replies.

Skute

Programmer
Jul 21, 2003
272
GB
Can anyone tell me if the following code *should* work?
Its just that pClientEnt is always NULL. That ip address is my local address, ive tried it with remote addresses (such as googles - 216.239.59.99) but it is still NULL.

strcpy(tNewClient.IPAddress, "192.168.1.26");
pClientEnt = gethostbyaddr(tNewClient.IPAddress, (int)strlen(tNewClient.IPAddress), tNewClient.SockAddr.sin_family);


gethostname works ok, it can detect my computer name, but i just cant detect who is connected to me.

Thanks
 
maybe you shold initialize like this:

char IPAddress[4] = {192, 168, 1, 26};
//this is not a regular string

and do like this:
gethostbyaddr(tNewClient.IPAddress, 4, tNewClient.SockAddr.sin_family);



Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top