Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Firewall or Routers preventing connection.  (Read 1430 times)
0 Members and 1 Guest are viewing this topic.
Offline zappsweden

Junior Member




Java games rock!


« Posted 2006-03-23 11:59:17 »

I am using Java1.4 and making a game using tcp/ip play. Both the client and server side will only work if the computer has no firewall or router preventing it (NAT Firewall for instance). I seen many games where you could at leist JOIN a game but not host, if u had these problems. If I could fix that workaround, it would mean a majority of players would be able to play, just they need 1 of the 2 being able to host. Anyone knows how to enable this?

I know the solution is that u open ports or forward ports but if any user is not able to do so, will it then automatically fail or can that user still be able to join?


Oh, by the way.


On the server side I use
ServerSocket listenSocket = new ServerSocket(Global.GAME_PORT);
           Socket clientSocket = listenSocket.accept();


On the client side i use
Socket serverSock= new Socket(this.connectToIP, Global.GAME_PORT);

Online Riven
« League of Dukes »

JGO Overlord


Medals: 606
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2006-03-23 12:38:51 »

Any client can connect to:
 - any server not behind a router
 - any server behind a router with the appropriate ports forwarded (NAT)

So the player that hosts the game has to have a server-setup like described above.
All others will find it.


Oh, and be sure to bind the ServerSocket to the public IP (or the local IP that is 'connected' to the router).

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline ryanm

Senior Member


Projects: 1


Used to be bleb


« Reply #2 - Posted 2006-03-23 14:05:13 »

You might find this thread useful.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #3 - Posted 2006-03-25 12:57:38 »

You might find this thread useful.

The UPnP library is a great piece of work, but most routers now come with it disabled for security reasons.  So rather than open a port, the user has to enable UPnP before the game (as a server at least) will work.  So it's questionable whether this is an improvement.

I had a go at this (networking, not UPnP)  last year and found that there's a number of other things worth thinking about...

The client-server model with the server not behind a router generally works well.  If the server is hosted on the same machine as a webpage hosting the applet or webstart app, then you may not even need to sign the applet/app (unless you want full screen, or native libraries, and for the second you might get away solely with a set of signed libraries).  The client server model also allows you to keep all the major game logic on the server, which is easier to program & allows easy storage of player game state.

However client-server routes all the data through the server.  Thus if you have 4 clients, each using 25kbps of bandwidth, then the server has to handle 100kbps.  If you had 10 players, this increases to 250kbps.  Overall, if the game is turn based, then the bandwidth per client is low, and you can use a client server model with no problem.  However, for a real time game, the data transmitted can quickly get out of hand, requiring a huge bandwidth at the server.  If this was paid for hosting, it would get expensive.  If it was a several megabit home broadband connection & the server was only up for a limited time, it'll probably be Ok.  Just estimate the bandwidth per player & calculate how many players can share the server.

Alternatively you could consider peer-peer networking.  Each client has to talk to every other client, so the client bandwidth increases significantly.  There is now a limit on the number of simultaneous players based on the player with the slowest connection.  It is also more difficult to program & you need to sign the app/applet so it can communicate to any address on the internet.  To make it work through routers, you need to use a technique called UDP Punch through. (Use google to find articles).  This needs a small server to make it work - The server tracks current players & allows new players to join.  Worth considering if you want to leave you server up all the time, but don't want to max out your bandwidth.


Time flies like a bird. Fruit flies like a banana.
Offline Jeff

JGO Coder




Got any cats?


« Reply #4 - Posted 2006-03-26 00:42:07 »

WHetehr ro not you can make an outbound TCPIP conectionre ally depends on teh firewall and configuration.

On MOST home firewalls by default you can, however many coproations block almost all outgoing ports on their foirewalls.

Simialrly on MOST home systems you can send a UDP packet out.  The firewall wil lautomagically map an external port for return messages and re-write that as well as the IP on the packet so IF the server uses the port and IP specified for return messages then they will get through.

However older firewalls may not and again corporate firewalls often block this.


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Online Riven
« League of Dukes »

JGO Overlord


Medals: 606
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #5 - Posted 2006-03-26 01:31:10 »

Ehm? The routers map the ports, not the firewalls.

Maybe you're talking about routers with embedded firewalls?

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Jeff

JGO Coder




Got any cats?


« Reply #6 - Posted 2006-03-26 03:27:11 »

Depends on the system.

On linux the firewall, IPChains, does port mapping.

**shrug**

In m sot common hosuehold situations yes the firewall is part of the router.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (64 views)
2014-04-15 18:08:23

BurntPizza (62 views)
2014-04-15 03:46:01

UprightPath (75 views)
2014-04-14 17:39:50

UprightPath (58 views)
2014-04-14 17:35:47

Porlus (76 views)
2014-04-14 15:48:38

tom_mai78101 (101 views)
2014-04-10 04:04:31

BurntPizza (161 views)
2014-04-08 23:06:04

tom_mai78101 (256 views)
2014-04-05 13:34:39

trollwarrior1 (209 views)
2014-04-04 12:06:45

CJLetsGame (216 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!