Archived

This topic is now archived and is closed to further replies.

Dogbert

[java] Networking causing applet to crash

Recommended Posts

This is the same game as I mentioned in the "screen update" post (I''ve cured the that problem now, thanks guys) but with a new problem! To recap: I''m developing a simple 2D top-down multiplayer Java game. Each player controls a tank that they use to shoot at other player''s tanks. I''m using the java.net.Socket class to send messages between players concerning the state of the game (e.g. where their tank is, its current speed, health level etc) through a central server program. My problem is that after about a minute of play the client program crashes (I''m developing on Solaris and using the KDE window manager which catches the crash and reports it as being a sigsegv fault). This problem does not occur if I run the game single player (i.e. not sending the messages across the network). I''m developing this using Java 1.1.6 (not Java 1.2 as it needs to run as an applet in Netscape) on Unix (Solaris, version 5.6 I think). Does anyone have any idea what could cause this kind of problem or a method of debugging this, I would be very grateful as its part of my university project and I''m running out of time. Thanks, Martyn (dogbert@madasafish.com)

Share this post


Link to post
Share on other sites
Its always cunning to setup an error log (then just tail the file). Do:
    
String logFilename = "/path/to/log/error_log";
PrintStream log = new PrintStream( new FileOutputStream( logFilename, true ) );
System.setErr( log );
System.setOut( log );

...now all output should go to that log file.


Share this post


Link to post
Share on other sites
Sounds like a bug in the VM. You are probably best trying to track down what the last thing is that the client does before crashing (just put println''s everywhere). Then you''ll probably have to code around the bug.
Are you running the clients in appletviewer or in netscape?
If it''s in appletviewer bobbins method should work fine, just make sure you flush the output every once in a while.

Share this post


Link to post
Share on other sites
I think it is a bug in the JVM. I only get the error when it is running in AppletViewer on unix. It does not happen when using netscape on unix or in AppletViewer on Windows 98.

Share this post


Link to post
Share on other sites