Jump to content

  • Log In with Google      Sign In   
  • Create Account

A "What's Next" Networking Question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 DontReferenceMyPointer   Members   -  Reputation: 139

Like
0Likes
Like

Posted 18 October 2012 - 12:35 AM

I'd like to preface this with that statement that I am not a Computer Science wizz. I'm a biochemist. So, please forgive my layman understanding of programming. Despite not being in a programming profession (I only write easy bioinformatics programs for work) , when I'm not in the lab I program in all of my free time! In particular, I love to program games. This summer I went a little crazy with the game making and made just a ton of different games. Some classics and some originals. I quickly realized that the next step would be to learn how to program a multi-player game.

I contacted one of my friends, an electrical engineer, about how to program a multi-player game and he told me to look into sockets. So, I found a few tutorials on socket programming (using java.net.* and java.io.*) and within forty five minutes I had a server and a client program. The server parsed input streams regarding character movement and reported them to the other clients. I could open up a few local clients and they would all show the main character from each of the clients running around. After a solid few seconds of fist pumping I sat back down and looked over the code to try and figure out what was really going on.

I realized, hey there's no place in this code where the client connects to the server on a non-local connection!

connection = new Socket(InetAddress.getByName("localhost").getHostName() , port #);...is not going to find a server on another computer over Al Gore's greatest invention!

It occurred to me that maybe I could just hard code the TCP/IP address into the client, but I know for a fact that my internet connection has a dynamic IP address, so no way that would work. This is not my area or expertise and I'm sure I'm just a google search away from a solid tutorial or explanation, however, I haven't been successful in finding a good answer. It reminds me of a student asks me what the pI of a certain protein is, after they have failed to figure it out for hours. My gut reaction is, "are you kidding me? It takes 5 minutes to figure that out." But then I remember that they don't have the tools and experience to even begin solving the problem.

So, my question is, what's next? What is the recommended way to get a client to connect to a non-local server using java.net.*?

By the way, I read through the article "Get Answers to Your Questions!"->Forum FAQ, Q0 is the best! I laughed so hard!

Sponsor:

#2 Ripiz   Members   -  Reputation: 529

Like
1Likes
Like

Posted 18 October 2012 - 03:47 AM

There's no way to connect if your address is dynamic. You need something static. The only thing that comes to my mind, use free website host or file host that allows direct linking (Dropbox for example), store .txt file that contains your current IP address. Client program could automatically load the page, copy address and connect to it. But you'd have to change it manually everytime your IP changes (unless you make another tool which would do that automatically).

#3 brx   Members   -  Reputation: 720

Like
1Likes
Like

Posted 18 October 2012 - 04:42 AM

There are services that provide dynamic dns lookup. This means that you install a little program that informs a server of your current ip address. It then routes the registered "domain" to that address. So basically, even though your actual IP changes there is a static hostname that will be updated whenever your IP changes.

There are several free providers for this kind of thing. One of the first ones (I think) was dyndns which I used for quite a while. There you registered a name (e.g. DontReferenceMyPointer.dyndns.com) and that one always pointed to your current IP address. However, looking at their website they don't offer a free service anymore. But I found a list of free provider: http://dnslookup.me/dynamic-dns/

#4 KnolanCross   Members   -  Reputation: 1293

Like
1Likes
Like

Posted 18 October 2012 - 10:31 AM

You should look for a dynamic ip service (I use no-ip - www.no-ip.com - for teamspeak / hobby games, it is free for non-commercial use).

If you are using a router, you can connect to it (moslty 192.168.0.1) and check if it provides a dynamic ip option. If it does, you can easily config it (mostly it will show a list of services it can interface with) by entering your username/password in the given provider.
If it does not you will need to download a program and install it, your pc will then inform the server of your current ip and it will redirect your domain to your new ip.

Also, if you are using a router, you will need to create a mac binding (so your pc will always have the same ip inside your local network) and then create a virtual server that will map the requests for your router to your pc.

Those are the very basic steps you need to follow, you can find very detailed tutorials on your chosen dynamic ip provider's site.

Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).


#5 DontReferenceMyPointer   Members   -  Reputation: 139

Like
0Likes
Like

Posted 18 October 2012 - 11:56 AM

Wow this is definitely another one of those situations, where I ask a question and I realize I may not even have the tools to understand and implement the answers!

But here's what I got from the answers (-) and my response and/or follow up question (+):

-(Ripiz) I need something to anchor my server or for my server to publish an IP calling card so that the clients can find it.
+It seems like writing to a *.txt file in a dropbox every loop through the server and having the client constantly check the dropbox to see if the server has changed may be suboptimal and error prone. (I know how to write to the dropbox, but I would have no idea how to make a client read from a dropbox on another computer.)
+Is it possible to have a server listen and create sockets through something constant like a web address? Or, is that totally unreasonable?

-(brx) I can register with a website that will report to my client the server operating machine's IP address.
+This sounds pretty promising, however, are there any security issues with this (the site says "secure" but I'd rather know an outsider's opinion) and can this be implemented into java (I don't understand how the new IP is reported to the client without writing code to do so in the client)?

-(KnolanCross) I need to expand my knowledge of IP and routers (which I am learning is even more limited than I thought.)
+I'll read through some dynamic IP tutorials and see if this helps solve my puzzle.

Thank you for all the replies! Please let me know if you find a serious error in my understanding or if you think I would benefit from reading some other materials!

#6 hplus0603   Moderators   -  Reputation: 5309

Like
2Likes
Like

Posted 18 October 2012 - 11:58 AM

This is also answered in the FAQ, which says you need a name to look up through DNS, and suggests using dyndns.org or similar to establish and update a name for your dynamic IP.
If you're new to network programming, I suggest you skim the FAQ, because it contains both help for newbies, as well as help for more advanced programmers, and when you get to a particular problem, you may then remember some question from the FAQ, and can go back and look it up there!

enum Bool { True, False, FileNotFound };

#7 DontReferenceMyPointer   Members   -  Reputation: 139

Like
0Likes
Like

Posted 18 October 2012 - 12:00 PM

This is also answered in the FAQ, which says you need a name to look up through DNS, and suggests using dyndns.org or similar to establish and update a name for your dynamic IP.
If you're new to network programming, I suggest you skim the FAQ, because it contains both help for newbies, as well as help for more advanced programmers, and when you get to a particular problem, you may then remember some question from the FAQ, and can go back and look it up there!


I do remember reading that, however, I don't think i understood what I was reading, so I didn't make the connection. I'll go back through the FAQ again now that I have better understanding of what I am looking for. Thank you!

#8 BeerNutts   Crossbones+   -  Reputation: 2946

Like
1Likes
Like

Posted 18 October 2012 - 12:50 PM

Not wanting to overlook Occam's Razor, if you just need a way to specific the IP address your server is running on, you can add a paramter to the client that accepts the IP address and port of your server, or, provide a method for the user to enter the IP address once the client has started.

Although, I think you're looking for the dynamic DNS solutions, I just wanted to make sure.
My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

#9 Eric Wu   Members   -  Reputation: 122

Like
0Likes
Like

Posted 22 October 2012 - 09:23 PM

There is an easy way, you can post your server IP in BBS or your blog, users can access the website and get server IP for login.
No need to change your codes except inputting the server IP in client login UI.

Edited by Eric Wu, 22 October 2012 - 09:29 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS