Jump to content
Sign in to follow this  
Dirk Diggler

TCPNameToIp bug or undocumented feature?

Recommended Posts

Dirk Diggler

Example

Func _HostIsOk($host_) ;  test if remote is exists.
    $host = $host_ 
    TCPStartup()
    if StringRegExp($host,"(([0-9]{1,3}\.){3}[0-9]{1,3})",0) = 0 then $host = TCPNameToIP ($host_)
    MsgBox(0,'',$host)
    TCPShutdown()
    if Ping($host) > 0  Then Return True
    Return False
    
EndFunc

MsgBox(0,'',_HostIsOk('microsoft.com')) 
MsgBox(0,'',_HostIsOk(''))

as u can see, TCPNameToIp for empty host name returns your own IP. is it normal?

Edited by Dirk Diggler

Share this post


Link to post
Share on other sites
Dirk Diggler

and another example:

Func _HostIsOk($host_)
    $host = $host_ 
    if StringRegExp($host,"(([0-9]{1,3}\.){3}[0-9]{1,3})",0) = 0 then $host = TCPNameToIP ($host_)
    MsgBox(0,'',$host)
    if Ping($host) > 0  Then Return True
    Return False
    
EndFunc
MsgBox(0,'',_HostIsOk(''))
UDPStartup()
MsgBox(0,'',_HostIsOk(''))

as u can see, without TCPStartup(), if run TCPNameToIP first time, it as documented, returns empty string. But if we runs UDPStartup(), it work like TCPStartup() - second time TCPNameToIP returns your own ip

Share this post


Link to post
Share on other sites
jpm

Your question is more a support question than a bug report.

It is true that UDPStratup is an alias of TCPStartup same for shutdown. It have been added for coherency.

For the value return on mpty string we use the gethostbyname Windows socket API so you get what MS want to return.

The local address does not seems incoherent :rolleyes:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.