GetHostByName function in CVF

GetHostByName function in CVF

I'm trying to use the GetHostByName() Windows Sockets function in my CVF program (just for fun :-)). But the IP address it returns is not correct. Here is the code:

subroutine InetCheck()
use dfwina
implicit none
type (t_in_addr) addr,adr
type (t_hostent) hp
type (t_wsaData) wsaData
integer ptr,sptr,i,aptr,address
character str*100,s*100
pointer (ptr,hp)
pointer (sptr,s)
pointer (aptr,addr)
pointer (adrptr,address)
call WSAStartup(MAKEWORD(2,2),wsaData);
write (str,'(i3)') &
127+LOBYTE(LOWORD(address)) ! First byte (unsigned)
if (WSAGetLastError().eq.0) call ShowMessage("Host",str)
if (WSAGetLastError().eq.0) call ShowMessage("Host",s)
call WSACleanUp()
end subroutine InetCheck

The WSAGetLastError function returns zero, but both messages (ShowMessage()) display various and wrong results!
If I try some IP address (for example, "") instead "" the result is not correct too (does not match with "").

What's wrong in my code?

Sorry for possible grammar and other mistakes.

Andrew, from Russia with love :-)

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.