Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get IP address of my computer
Thank Gintaras.

but i has some question.

What function return IP ADDRESS ? Confusedhock:
You can search the internet for source code that contains functions


Maybe some easier function also exist.
so Sorry
I'm mean my computer IP ADDRESS.
Yes, host is your computer, and IP that these functions return is like 123.456.789.123
I can found.

int WINAPI2.gethostname($name namelen)
*hostent WINAPI2.gethostbyname($name)

What mean $name ?
Name of computer name? :oops:
Read about it in the MSDN library on the internet. I think it must be str variable, and the function populates it with your computer name. At first allocate namelen bytes.

Or go to a website that shows your computer IP. For example
Function GetMyIpAddress
Copy      Help
function# str&ip

;Retrieves IP address of this computer.
;If there are multiple IP addresses, they are stored in multiple lines.
;Returns 1 on success, 0 on failure.

;str ip

,;out ip

int+ __wsa_init
,WSADATA wsaData

hostent* hp = gethostbyname(0); if(!hp) ret
int i
for i 0 1000
,if(hp.h_addr_list[i] && hp.h_length>=4) else break
,if(i) ip+="[]";
,byte* b=hp.h_addr_list[i]
,ip.formata("%u.%u.%u.%u", b[0], b[1], b[2], b[3])
if(ip=="") ip="";
ret 1
Thank you very much .Gintaras Big Grin

Forum Jump:

Users browsing this thread: 1 Guest(s)