Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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  
  Network Error with my Multiplayer Pong (First Attempt)  (Read 872 times)
0 Members and 1 Guest are viewing this topic.
Offline RyanMB97

Junior Member


Medals: 1
Projects: 1



« Posted 2013-06-08 13:19:50 »

Hello! This is my first attempt at creating an "online" game. I've created a chat client, which is actually quite easy compared to game networking. Anyways, I'm pulling some odd errors that I have no idea how to fix. Here's a Github of the project I created:
https://github.com/RyanMB97/MultiplayerPong
I also have some images:
Server Error: As can be seen, the program itself works, but the networking throws an error while listening for the client

Client Error: Program doesn't work at all, and I'm not sure why...


The "Server" is being run on my own desktop computer, and the "Client" is being run on my brother's laptop. We are connected via a WiFi signal to the router, so I wasn't sure which IP to connect to. We've been using my external, which has the port (7777) forwarded that we're using. Thanks in advance for and and all help!
Offline matheus23

JGO Kernel


Medals: 108
Projects: 3


You think about my Avatar right now!


« Reply #1 - Posted 2013-06-08 13:26:52 »

The ConnectedPlayer's DataInputStream is set to null...

Come on, this is a simple NullPointerException, the famous NPE, the million dollar mistake...

Should always be easy to fix.

The better question should be:
Why is the 'in' DataInputStream in this line
null
, even though you create a new instance right above that line...

Need to look a little into the code. Try to debug it with eclipse or any other IDE.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline RyanMB97

Junior Member


Medals: 1
Projects: 1



« Reply #2 - Posted 2013-06-08 13:33:39 »

I know about the NPE and everything, but there isn't any obvious reason for it to appear. It runs perfectly fine when using localhost during Eclipse debug-runs, but as soon as I try to connect from anywhere that's not localhost, or another computer, it throws the errors. I'm currently using Eclipse, and it doesn't give any warning or pointers to anything. Usually, asking for help is my last resort, so I'm really stuck on this one part. I double checked the way that the inputstream you mentioned is made, I it looks/seems fine to me. You wouldn't happen to have any ideas, would you?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline davidc

Senior Member


Medals: 5
Projects: 2



« Reply #3 - Posted 2013-06-09 01:20:37 »

At the risk of sounding like a broken record, you need to stop interfering with Java's exception handling model. I've seen quite a few places in your code where you catch exceptions rather than let them propagate, but do nothing with them except sometimes write to System.out. The program just continues on as if nothing went wrong, resulting in NPEs later on. This makes debugging so much harder than it needs to be.

Learn to use the throws clause. Don't write catch blocks unless you can do something appropriate with the exception. Remember - exceptions are like alarms. All catching them does is turns the alarm off. If you aren't doing something to handle the exception, don't catch it.

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.

Pippogeek (38 views)
2014-09-24 16:13:29

Pippogeek (29 views)
2014-09-24 16:12:22

Pippogeek (18 views)
2014-09-24 16:12:06

Grunnt (42 views)
2014-09-23 14:38:19

radar3301 (24 views)
2014-09-21 23:33:17

BurntPizza (61 views)
2014-09-21 02:42:18

BurntPizza (31 views)
2014-09-21 01:30:30

moogie (36 views)
2014-09-21 00:26:15

UprightPath (49 views)
2014-09-20 20:14:06

BurntPizza (53 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!