Find ur ip
Blitz3D Forums/Blitz3D Programming/Find ur ip
| ||
Hey, I need some help on this, and I'm sure it easy... I am working on some networking thing, and I need to send to a FTP a file that includes, the computer that I'm using ip. all I need is that you would tell me how to find my ip(with blitz of course)... thx in advance |
| ||
No one willing to answer?... |
| ||
I believe like this:ips = CountHostIPs("") If Not ips Then End hip = HostIP(1) Print DottedIP(hip) |
| ||
Hey thx for replying, but i checked this out, and it gives me "10.0.0.1", and i want the ip that the ISP gives me... do u know how to do that? |
| ||
Ow .. oke .. erm second attempt:For i = 1 To CountHostIPs("") hip = HostIP(i) Print DottedIP(hip) Next WaitKey() End |
| ||
well done, it works really fine, thank you. there is only 1 problem, but its not really a matter, that it prints "10.0.0.1" first, and then it prints the ip that the ISP provides me. But i am just letting you know that, i don't really need that you will fix it... |
| ||
That tells you the local ip: 10.0.0.1 means you are behind a router, it is not the real ip. Just the local ip your router gives to the concrete computer you are using. To know your real ip, you have to check the setup page of your router. |
| ||
Well its now about 0.5 year i didnt used Blitz3D so tell me whats wrong here because it doesn't create the file somewhy:Include "FTPFunctions.bb" AppTitle "Client" For i = 1 To CountHostIPs("") hip = HostIP(i) Print DottedIP(hip) Next Print "Connecting to server..." FTP_Connect("***","***","***","") Print "Connected..." Print "Creating file containing your ip..." CreateDir("ip") ipfile=WriteFile("ip\"+hip+".dat") WriteString(ipfile,hip) CloseFile(ipfile) Print "Sending your ip to the server..." FTP_Put("ip\"+hip+".dat",1,GraphicsWidth/2,GraphicsHeight/2) Print "Finished..." WaitKey() End Edit:I'll create a new topic for that since no one answering... |
| ||
ok, now there is another problem, the code up there works fine, but the file created is called "1502239067.dat" while my ip is 89.138........ |
| ||
It could take a while for people to respond. Say, if your topic is 4 days old, and nobody responds, then either nobody knows or people didn't like the question. :D About the ip's: I don't know too much about this, but I can imagine that there is some kind of logic in the order of the IP's. Say, the first IP is for your PC, the next one for the router .. etc .. So, although I'm not sure, you could try to read only the last IP that is returned. 'hip' contains a number, to convert it to a dotted IP, use DottedIP() |
| ||
And for the file you probably should try: WriteLine(ipfile,hip) instead. |
| ||
That tells you the local ip: 10.0.0.1 means you are behind a router, it is not the real ip. Just the local ip your router gives to the concrete computer you are using. To know your real ip, you have to check the setup page of your router. Not necesarily, you can also use a 3rd party server on the internet to tell you what IP your request came from. That way it works everywhere, regardless of what router you use or if you have a login to it. e.g. http://www.ippages.com/simple or http://whatismyip.com don't have any B3D code though, but it's pretty easy under BMax. :-? (Oops, didn't see tha |
| ||
OK, thx all of ya... i've figured out the problem... here is the code: Include "ftp.bb" AppTitle "client" For i = 1 To CountHostIPs("") hip = HostIP(i) Print DottedIP(hip) Next Print "Connecting to server..." FTP_Connect("***","***","***","") Print "Connected..." Print "Creating file containing your ip..." CreateDir("ip") ipfilename$="ip\"+DottedIP(hip)+".dat" ipfile=WriteFile(ipfilename$) Writeline(ipfile,DottedIP(hip)) CloseFile(ipfile) Print "Sending your ip to the server..." FTP_Put(ipfilename$,1,GraphicsWidth/2,GraphicsHeight/2) FTP_Quit() WaitKey() End |