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

but i has some question.

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

gethostname
gethostbyname

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

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

What mean $name ?
Name of computer name? :oops:
#6
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 http://www.whatismyip.com/
#7
Function GetMyIpAddress
Code:
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.


;EXAMPLE
;str ip
;if(GetMyIpAddress(ip))

,;out ip


int+ __wsa_init
if(!__wsa_init)
,__wsa_init=1
,WSADATA wsaData
,WSAStartup(0x0002,&wsaData);

hostent* hp = gethostbyname(0); if(!hp) ret
int i
ip=""
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=="127.0.0.1") ip="";
ret 1
#8
Thank you very much .Gintaras Big Grin


Forum Jump:


Users browsing this thread: 1 Guest(s)