Jump to content
  • Advertisement
Sign in to follow this  
vidjogamer

[java] help appreciated

This topic is 3614 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

so im stuck in a group in class and we have to make a networked game... the game itself is functioning properly but for some reason we cant get them to network... sorry, we put println's after everything to see if it worked. i apologize for the sloppy code... heres the part that doesnt work: while(board2 == null) { try { //System.out.println("Searching for connection"); socket = new Socket("localhost",7000); System.out.println("Connected to Server."); System.out.println("Waiting for player 2"); ObjectOutputStream toServer = new ObjectOutputStream(socket.getOutputStream()); ObjectInputStream fromServer = new ObjectInputStream(socket.getInputStream()); System.out.println("streams work"); board1 = new ColumnsBoard(this); System.out.println("board1 works"); toServer.writeObject(board1); System.out.println("write board works"); board2 = (ColumnsBoard)fromServer.readObject(); System.out.println("board 2 works"); } catch(Exception ex) { } } It never gets to the System.out.println("write board works"); any help is appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by vidjogamer
catch(Exception ex)
{

}


Never drop an exception. Always print out what is going on. Right now you have no way of know if an exception occured.

Also you should always catch the specific exception that you are looking for. In this case it is an IOException. So you should use.

try {
//your code
}
catch(IOException e) {
e.printStackTrace();
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!