sockets help

Moohooya

Senior member
Oct 10, 1999
677
0
0
I there a detailed socket FAQ/reference/guide available on-line as I need some general socket info.

But my specific question is as follows. I have a host name, which I can get an ip address for. When however I call gethostbyaddr passing the correct inetaddress I get back WSANO_DATA. If however I call gethostbyname I get the HOSTENT structure returned.

What gives? Shouldn't both calls be looking up the same record on the name server, but just using different indexes, or are these two fundamentally different functions? I've also not found any decent description of the error WSANO_DATA, but I guess it means the name server has no record for the ip address.

Very confussed,

Moohoo
 

michaelh20

Senior member
Sep 4, 2000
482
0
0
My only thought would be, if you are on a Intel machine, you need to do a host to network long (I think) htnl or something on the number you use for the IP lookup. That is, provided, you didn't already get that number from the network.
 

Moohooya

Senior member
Oct 10, 1999
677
0
0
Thanks michaelh20,

I was correctly doing the htonl but never knew about the google group search. Thanks fot the link, I'll see what they say.
 

Moohooya

Senior member
Oct 10, 1999
677
0
0
Ah got it, thanks. I was passing a pointer to the sockaddr. sa_data structure in which the first two bytes are the port number and not the IP address.

Any one know of any good socket references out there? Winsock & Berkely preferably, but I'd settle for just one.

Thanks