Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How can i get ip address?

Author
Message
Legends
14
Years of Service
User Offline
Joined: 31st Jul 2011
Location:
Posted: 31st Aug 2011 12:10
Okay, i am working on online game. I must know another people Ip address if i want join their game. I have ftp server and i want send games servers Ip to ftp server. But my problem is, how can program get Ip? I don't find command IP(), and it returns your ip address. Can someone help?
basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 31st Aug 2011 17:45
1-if you're using DBpro core commands, the search can be automatic.

2-FTP commands don't work on WAN. it only works on LAN.

3-if you have a server then people should join you, not the opposite.

4-if you own a copy of "enhancement pack" then you have this command:

IP$=GET IP ADDRESS$()
miso
16
Years of Service
User Offline
Joined: 16th Jun 2010
Location: Budapest, Hungary, 127.0.0.1
Posted: 31st Aug 2011 20:06 Edited at: 31st Aug 2011 20:09
Basjak is right, file transfer protocol is absolutely not for games.

Answering your question, you will find some useful command in ians matrix1 plugin.

Check the commands under the title "local interfaces".

http://www.matrix1.demon.co.uk/Matrix1Utils_Help/Matrix1Util_28_index.html

No place like 127.0.0.1 .
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 31st Aug 2011 23:14
The IP addresses you get from my plug-in are the IP addresses of the local network devices - if you use a router to access the Internet then you'll have a completely different IP address there, and my commands can't help you directly.

For example, you may have an IP address of 192.168.1.2 on your local machine, which connects to a router as a gateway with an IP address of 192.168.1.1 on your local network. The external side of the router will have an Internet address (for example) 66.12.34.56, and that's the IP address you'll want people to know so that they can connect to you.

After all that waffling, I guess I'd better tell you how to get that IP address - you can do it using DBPro's built-in HTTP commands, and a bit of string manipulation.

There are sites on the Internet that exist purely to tell you your IP address, such as ipcheckit.com - the reason I picked that one is that DBPro's HTTP commands can only connect to HTTPS sites, and ipcheckit.com happen to accept the HTTPS protocol.

Here's the code you can use to get the IP address from that site:


miso
16
Years of Service
User Offline
Joined: 16th Jun 2010
Location: Budapest, Hungary, 127.0.0.1
Posted: 1st Sep 2011 00:08 Edited at: 1st Sep 2011 00:13
All my respect is yours Ian, but I dont want to use an external site to get this.

I can still use the perform checklist for interfaces command to get the needed data. (I dont have a router at the moment to try, im connecting directly, but I think the router would be in the list too)

All I have to know, how to close out the ips that are not dhcp IPs or hamachi IPs.

Checking Value A and Value D, I have to abandon IPs 0.0.0.0 "unknown" ,127.0.0.1 "localhost", 192.168.x.x "local",
10.x.x.x "local", 5.x.x.x "Hamachi interface", 172.16.x.x-172.32.x.x "reserved".

The remaining one IP will be my external IP, if I'm connected.

If I'm not right, please correct me.

No place like 127.0.0.1 .
Mugen Wizardry
User Banned
Posted: 1st Sep 2011 00:13
You can't do that. It's impossible. Next time, listen to the mod -.-

Your external IP is NOT on your network card. It is given to you by your service provider.

You're either gonna have to use the above code, a php script and read the IP, or make dbpro read an external c++ or visual basic script program that does that for you.

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Sep 2011 01:11
There's an expression around here (if there isn't there should be) "if IanM don't know, it probably isn't worth knowing!"

Btw, thanks for the code IanM that's really handy

miso
16
Years of Service
User Offline
Joined: 16th Jun 2010
Location: Budapest, Hungary, 127.0.0.1
Posted: 1st Sep 2011 01:15 Edited at: 1st Sep 2011 01:17
Well, true. I inserted my router to my machine, but even ipconfig doesnot shows it... that's just sad, that there's no other "a better" solution...

Thank you Mugen for giving me a lamp, so I was able to seek my way out of the valley of darkness, you are so kind.

All my miscalculation was that belief, that the router will appear in the list too if connected, but I was wrong.

No place like 127.0.0.1 .
Legends
14
Years of Service
User Offline
Joined: 31st Jul 2011
Location:
Posted: 1st Sep 2011 12:02
No i have second problem, how can i stop pop up window? (It says "locate the session" and then i must press enter and game works...)
So how can i stop it?
Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 2nd Sep 2011 04:42
Just FYI I'm pretty sure there is a protocol that allows you to query the router for its WAN address, but I don't know much about that. Either way it'd be easier to simply query an external site.



Support a charitable indie game project!
Legends
14
Years of Service
User Offline
Joined: 31st Jul 2011
Location:
Posted: 2nd Sep 2011 13:53
ÄÄhh... Default net connecting find me, when i open game two times. When i open game in my computer and in my friend computer, game doesn't find each other. It works only when we are in same local network area (lan). What does i do wrong?
miso
16
Years of Service
User Offline
Joined: 16th Jun 2010
Location: Budapest, Hungary, 127.0.0.1
Posted: 2nd Sep 2011 19:28 Edited at: 2nd Sep 2011 22:55
You are doing nothing wrong, its how it works. One of you has a router, and thats what hamachi was made for. Personally, I dont like hamachi either, but that will be the solution, if you want to use the built in networking commands of dbpro.

(It works over internet normally without the hamachi, if both of you connecting to the net directly.)

No place like 127.0.0.1 .
Legends
14
Years of Service
User Offline
Joined: 31st Jul 2011
Location:
Posted: 2nd Sep 2011 19:55
Aaa, okay.... Does dprpo have network add on, which work over internet?
miso
16
Years of Service
User Offline
Joined: 16th Jun 2010
Location: Budapest, Hungary, 127.0.0.1
Posted: 2nd Sep 2011 23:11 Edited at: 2nd Sep 2011 23:26
There are a couple around. Darknet or Mikenet costs some $$, but its well designed to use. There are some free plugin too. I found, that most user here prefer multisync, but if you dont mind a bit more low level programming, you can use Barnski's Winsock or Ian's Matrix1 for UDP networking.

You may find Barnski's winsock here: http://homepage.hispeed.ch/barnski/main.htm

Ian Mold's Matrix1 here: http://forum.thegamecreators.com/?m=forum_view&t=85209&b=18

Benjamin's Multisync here: http://forum.thegamecreators.com/?m=forum_view&t=99188&b=5

Multisync UDP here: http://forum.thegamecreators.com/?m=forum_view&t=158160&b=8

Darknet here: http://www.thegamecreators.com/?m=view_product&id=2070

There was an UDP plugin floating around called Tempest, but I think the author removed that one.

No place like 127.0.0.1 .
Hybrid1973
14
Years of Service
User Offline
Joined: 29th Oct 2011
Location:
Posted: 6th Nov 2011 03:26
If someone - just like me - doesn't have the "instr" command here is the function:

JRNTexas
15
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 6th Nov 2011 04:23 Edited at: 6th Nov 2011 04:42
Here is another set of code that I got off of the forums but can't find it again:



This code only gives your IP on the local network, if that happens to be the Internet, then you get your Internet IP address. However, IP ADDRESS$() is much easier!

@basjak

Quote: "2-FTP commands don't work on WAN. it only works on LAN"


Just an FIY, I've gotten the FTP commands to work over the Internet, not just the local network.
basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 6th Nov 2011 08:28
I'd love to know that am wrong but I tried very hard and couldn't get it work. later, lee confirmed it for me in the forum.

from DBpro point of view, FTP commands don't work over the internet neither mike net.

KIStech claimed that he's got the answer but I had to pack my project for later effort.
These words are by KIStech at my thread: [email]http://forum.thegamecreators.com/?m=forum_view&t=186814&b=1[/email]
Quote: "Ok, here is an answer from someone who runs a DBPro server on a dedicated machine. I run my own hosting, so I know what I'm doing.

Forget about the built in networking commands. They are based on DirectPlay and unless you are only supporting a few players, they stink.

Multisync is a great free alternative, and if you require encryption and (when he adds it) compression, DarkNet is my favorite choice.

- Windows 2003 Server will NOT work. Even if it supports DX9. The DBPro app either freezes or gives an error about finding the video card. It's just something about the way they did the graphics on the server that doesn't work.
- Windows 2008 Server MIGHT work, but I wouldn't count on it.
- You will need a desktop OS installed. (XP or Win7)
- RealVNC will work for remote control if you don't use any graphics on the server app. Make your server screen text only and it will work. I do it all the time.

Finding someone that will host a desktop OS might be difficult if not impossible. If I can set up one of my new servers with VMWare and run a few copies of XP on it, I might consider hosting some game servers. I've got the right facilities and a 25/25mbit fiber connection.

Let me know the best quotes you've gotten for hosting and I'll see if I can match or beat that price. Email me if you like."
JRNTexas
15
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 6th Nov 2011 15:37 Edited at: 6th Nov 2011 15:40
@basjak

Here is the code I used (right out of help). I used my server, on the Internet and was able to retrieve files, send files, change directories, etc.



If you still have problems, I'd be glad to send you the code with my "test" server so you can see it work. Just send me an email.
basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 6th Nov 2011 17:39 Edited at: 6th Nov 2011 17:40
@JRNTexas

thanks, i have weakness when it comes to servers because I never owned one.
please, can you leave an answer to my thread because I would like to start from there.

http://forum.thegamecreators.com/?m=forum_view&t=186814&b=1

I'm more likely prefer to rent a remote server because my internet is shared in the house.

Login to post a reply

Server time is: 2026-07-10 01:59:32
Your offset time is: 2026-07-10 01:59:32