Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (583)
Games in Android Showcase (163)
games submitted by our members
Games in WIP (633)
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 1679 times)
0 Members and 1 Guest are viewing this topic.
Offline zappsweden

Junior Devvie

Java games rock!

« Posted 2006-03-23 10: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);

Offline Riven
« League of Dukes »

« JGO Overlord »

Medals: 981
Projects: 4
Exp: 16 years

Hand over your head.

« Reply #1 - Posted 2006-03-23 11: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 Devvie

Projects: 1
Exp: 15 years

Used to be bleb

« Reply #2 - Posted 2006-03-23 13: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 11: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-25 23: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!
Offline Riven
« League of Dukes »

« JGO Overlord »

Medals: 981
Projects: 4
Exp: 16 years

Hand over your head.

« Reply #5 - Posted 2006-03-26 00: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 01:27:11 »

Depends on the system.

On linux the firewall, IPChains, does port mapping.


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!
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Ralphanese (22 views)
2015-05-29 13:07:55

Gibbo3771 (18 views)
2015-05-29 06:54:17

Ralphanese (23 views)
2015-05-28 16:52:52

theagentd (31 views)
2015-05-27 22:21:17

theagentd (38 views)
2015-05-27 22:21:08

CopyableCougar4 (27 views)
2015-05-27 19:24:50

MrMapcom (24 views)
2015-05-23 20:26:16

MrMapcom (33 views)
2015-05-23 20:23:34

Waterwolf (39 views)
2015-05-20 15:01:45

chrislo27 (46 views)
2015-05-20 03:42:21
Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02 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‑
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!