|
nymon
|
 |
« on: November 07, 2006, 01:36:32 PM » |
|
Hey Darkfrog,
I'm ready to roll JGN into a game, but was thinking some stuff out before hand. What is the best way to search for and list JGN servers which are running on a LAN? I was reading an old post about ServerRegister but couldn't really follow it, and I couldn't find it in the source.
Is there a built in way of doing this?
|
|
|
|
|
Logged
|
|
|
|
|
darkfrog
|
 |
« Reply #1 on: November 07, 2006, 02:06:33 PM » |
|
There was in 1.0 but it didn't make it into 2.0. I really need to go back and add that feature. The ServerRegistry was essentially just a system that would allow you to register MessageServers with it based on a "group name" and so someone could hit that centralized server and give a group name (say for the specific game they want to play) and it would return a list of all the available servers back.
It's a pretty simple system, but if that's something you're ready to start using I'll make it a priority to get it in. I will be needing it for another game eventually but had sort of put it on the back-burner until I need it.
|
|
|
|
|
Logged
|
|
|
|
|
nymon
|
 |
« Reply #2 on: November 07, 2006, 05:50:28 PM » |
|
I hate to rush but it is something I would love to have. It's not essential for me immediately, but the sooner the better. My plan was to have the networking in place within 2 weeks, assuming nothing holding me back. This is, in all reality, for convenience and there is no reason I could not proceed without it.
What I understand about what you just explained, the user would need to know the address of the system hosting the ServerRegistry in order to query it. Are there any unwritten (or written) rules against a port scan of the computers in a LAN so the user need not know anything, its just magic?
|
|
|
|
|
Logged
|
|
|
|
|
darkfrog
|
 |
« Reply #3 on: November 07, 2006, 06:19:03 PM » |
|
Well, that's always another route to go. You wouldn't want to do a portscan per se, but you might have a specific connection port that is required to be open for your game and simply scan the subnet trying to establish a connection. I believe that's how LAN games typically work. As for something like BF2 they have a registry that you contact for a list. A server has to "check-in" with the registry every so often or they get dropped from the list.
If you decide to go the LAN style route (which obviously wouldn't work for internet games) I would be happy to help you get that set up. It should be extremely straight-forward with JGN without any additional features.
|
|
|
|
|
Logged
|
|
|
|
|
nymon
|
 |
« Reply #4 on: November 07, 2006, 06:46:42 PM » |
|
At this point I think keeping down to a LAN would be acceptable. have a specific connection port that is required to be open for your game and simply scan the subnet trying to establish a connection Exactly what I had in mind! Thanks for offering to help. Is there a specific setup which I should follow that would cater to this, or is all the same? I've run all the tests and examples you've provided and If the general setup is not different than what I can find there I'll go ahead see what I can flesh out. The subnet scan is something I'll have to research, unless soliciting your help is all the research I need. Also, do you recommend your last release or pulling the cvs at this point?
|
|
|
|
|
Logged
|
|
|
|
|
darkfrog
|
 |
« Reply #5 on: November 07, 2006, 08:19:50 PM » |
|
The subversion source is pretty stable right now so feel free. I always give plenty of notice if I'm going to create any instabilities in the repository and create a release that can be fallen back on if problems do occur as a result.
You can rely pretty closely with the examples, that should be fine.
As for the subnet scan you should just be able to grab your own local IP address and rip off the last number and start a scan from 1 - 255 and try to connect.
|
|
|
|
|
Logged
|
|
|
|
|
nymon
|
 |
« Reply #6 on: November 07, 2006, 10:16:32 PM » |
|
Thanks for the pointer. I'll keep you posted of any deep findings. 
|
|
|
|
|
Logged
|
|
|
|
|
nymon
|
 |
« Reply #7 on: November 08, 2006, 10:26:21 AM » |
|
Now when doing the scan, do I have to attempt a TCP connection to each address, or can I rapid fire UDP's and wait for responses? The fastest way is what I'm looking for.
|
|
|
|
|
Logged
|
|
|
|
|
darkfrog
|
 |
« Reply #8 on: November 08, 2006, 10:43:34 AM » |
|
That's actually a really good point. I might add a feature to JGN to have something like: boolean JGN.isServerAtAddress(InetSocketAddress, Type, int timeout) Type would represent UDP or TCP. I started working on the ServerRegistry and it will be far superior to the original one and much more extensible.
|
|
|
|
|
Logged
|
|
|
|
|
nymon
|
 |
« Reply #9 on: November 08, 2006, 11:11:25 AM » |
|
What is a reasonable timeout when waiting for a response? Of course it depends on the network, but for a regular LAN is something like 10ms too short or too long?
|
|
|
|
|
Logged
|
|
|
|
|
nymon
|
 |
« Reply #10 on: November 08, 2006, 11:13:26 AM » |
|
Also, do I have to wait for the timeout before checking another address or can I send as fast as I can and just catch the responses as they come?
|
|
|
|
|
Logged
|
|
|
|
|
darkfrog
|
 |
« Reply #11 on: November 08, 2006, 12:55:26 PM » |
|
Good point....I will consider this much more as I think I could come up with an NIO approach to that where you can cycle through all the addresses you want to hit and give it a timeout (probably 1 second) and get a reference that you can check back with to see if it has timed out or gotten a valid response.
If you're willing to wait a couple days on this one I'll get something into the core of JGN to add support for TCP and UDP.
|
|
|
|
|
Logged
|
|
|
|
|
nymon
|
 |
« Reply #12 on: November 08, 2006, 01:18:02 PM » |
|
Yeah I'll wait, Thanks
|
|
|
|
|
Logged
|
|
|
|
|
kine
|
 |
« Reply #13 on: September 15, 2008, 05:18:18 AM » |
|
Hi All !  Darkfrog, did you finally implement smt like boolean JGN.isServerAtAddress(InetSocketAddress, Type, int timeout) ? Can you explain me a bit what instructions are needed to scan a lan, at least how to retrieve lan adresses ? Tanks in advance Kine
|
|
|
|
|
Logged
|
|
|
|
|
darkfrog
|
 |
« Reply #14 on: September 15, 2008, 07:19:31 AM » |
|
No, I never got around to this, but if you're interested in writing it and contributing back that would be greatly appreciated.  The easiest way is to gather the machine's IP addresses (exclude 127.0.0.1 obviously) and then replace the last digit with your scan 1 - 255. If you do this non-blocking (as opposed to scan and wait) you could simultaneously send requests to all 254 (exclude the local IP) addresses and give a certain amount of time for them to respond. However, you could also look into multicast and though JGN doesn't have built-in support for this for this scenario it would really be powerful.
|
|
|
|
|
Logged
|
|
|
|
|