Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 2580 times)
0 Members and 1 Guest are viewing this topic.
Offline RyanMB97

Junior Devvie

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:
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: 138
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
, 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 Devvie

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 Devvie

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  

EgonOlsen (78 views)
2018-06-10 19:43:48

EgonOlsen (58 views)
2018-06-10 19:43:44

EgonOlsen (78 views)
2018-06-10 19:43:20

DesertCoockie (260 views)
2018-05-13 18:23:11

nelsongames (158 views)
2018-04-24 18:15:36

nelsongames (157 views)
2018-04-24 18:14:32

ivj94 (898 views)
2018-03-24 14:47:39

ivj94 (162 views)
2018-03-24 14:46:31

ivj94 (811 views)
2018-03-24 14:43:53

Solater (175 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!