Cthulhu Posted November 25, 2005 Share Posted November 25, 2005 (edited) Hello folks! I'm new with AutoIt and I'm facing a problem trying to find information on how can I use Winsock functions with it. I'm trying to write a function that gets the IP Address of a given url, but I don't know how can I declare the hostent structure: struct hostent { char FAR * h_name; /* official name of host */ char FAR * FAR * h_aliases; /* alias list */ short h_addrtype; /* host address type */ short h_length; /* length of address */ char FAR * FAR * h_addr_list; /* list of addresses */ #define h_addr h_addr_list[0] }; Any help? Edited November 25, 2005 by Cthulhu Link to comment Share on other sites More sharing options...
eVAPor8 Posted November 30, 2005 Share Posted November 30, 2005 1. Grab the beta version 2. Look up TCPNameToIP 3. Shout "Thank you Larry" very VERY loudly. (Larry seems to do most of the TCP dev work - Apologies if I've credited the wrong person!) -OR- Can't help you with defining struct's - I'm new to Au3 myself - but if all you need is the IP, the code below may help. (I used some imagination based on the _GetIP function) It's not exactly elegant, but may be a way around a problem. It requires the server to reply to Ping requests, which makes it unreliable in all circumstances: msgbox (0, "IP of URL", _GetIPofHost("www.google.com")) Exit Func _GetIPofHost($hostname) Dim $ipinfo Dim $x Dim $y ;pipe the result of ping to file RunWait(@ComSpec & " /c " & "ping -n 1 " & $hostname & " > " & @TempDir & "\~i.tmp", @TempDir, @SW_HIDE) ;read and delete temp file $ipinfo = FileRead(@TempDir & "\~i.tmp", FileGetSize(@TempDir & "\~i.tmp")) FileDelete(@TempDir & "\~i.tmp") ;this next bit is nasty...needs a better Autoit user to clean up with a RegEx or something! $x = StringInStr($ipinfo,"[") + 1 $y = StringInStr($ipinfo,"]") - $x $ipinfo = stringmid($ipinfo, $x, $y) Return $ipinfo endfunc Link to comment Share on other sites More sharing options...
jpm Posted November 30, 2005 Share Posted November 30, 2005 You credit the right person for TCP UDP is /dev/null Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now