Version: 1.00.00 - last Update: Friday, October 02, 2009, 19:10:00

Previous ChapterFoxtools Home (Alphabetical TOC)Foxtools Home (Grouped TOC)Next Chapter

Foxtools WinSock Library Functions


_WSockGetHostByAddr() is the second of three Foxtools functions that were added by Calvin Hsia. WSockStartUp() initializes the Winsock library. Call _WSockStartUp() and _WSockCleanUp() to initialize/uninitialize the Winsock library. The _WSockGetHostByAddr() function finally takes an IP address string like "" and resolves it into the name of the machine.

_WSockGetHostByAddr() wraps the Windows Socket function gethostbyaddr() <<< go there to find out the details!  The following part is "borrowed” from Microsoft’s msdn Winsock Reference:

The gethostbyaddr function retrieves the host information corresponding to a network address. Note: The gethostbyaddr function has been deprecated by the introduction of the getnameinfo function. Developers creating Windows Sockets 2 applications are urged to use the getnameinfo function instead of the gethostbyaddr function. (As we cannot switch to the new GetNameInfo() internally, this information is of no big use for us.)

If you followed the link above you may know by now that there are a lot of different return/error values. All of these are eaten by the Foxtools wrapper. Instead, our Foxtools function solely returns 1 or 0 flagging success or failure.

VFP Syntax

iSuccess = _WSockGetHostByAddr(m.cIPAddress, @cHostName)


[in] cIPAddress

The IP address of the computer to be resolved - a String-parameter like “”.

[in] cHostName

Buffer variable that must have been defined before the call. _WSockGetHostBy Addr() returns the computer name in this variable if successful.

VFP Example(s)

Calling the _WSockGetHostByAddr() function can be accomplished with the following:

STORE 0 to buff1, buff2, buff3, buff4, buff5, buff6
IF _WSockStartUp(256 + 1, @buff1, @buff2, @buff3, @buff4, @buff5, @buff6) = 0 
   *\\ use your local IP address here
   IF _WSockGetHostByAddr("", @buff1) = 1 
      ? m.buff1 
      Error “_WSockGetHostByAddr errorENDIF 
   = _WSockCleanUp()

Previous ChapterFoxtools Home (Alphabetical TOC)Foxtools Home (Grouped TOC)Next Chapter