• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Client server help

 
jon ladd
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a client server program. First you have to laod the server, create a file for the has map to write to then start the client portion. Once the client is running when i type in a name and try to add a name and number it just says invalid number. It not writing from the client server. Any ideas on why it is not doing that would be very helpful.

 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would probably make things easier for both of use if you'd start from scratch. Write a client and a server that just send a string back and forth. Then add a feature, like sending a Person object, and get that to work. It would be far simpler to narrow down what isn't working in that case than plowing through this 1000 lines of code, not to mention you'd have a better grasp as to what's going on in your code.
It would pay to become familiar with the API Documentation. For example, you may have noticed that in the entry for java.io.ObjectInputStream it says:

The ObjectInputStream constructor blocks until it completes reading the serialization stream header. Code which waits for an ObjectInputStream to be constructed before creating the corresponding ObjectOutputStream for that stream will deadlock. . .

In other words, your server thread never starts up because execution is blocked on fromClient = new ObjectInputStream(connection.getInputStream());
One useful debug technique is putting System.out.println(""); statements everywhere and watch the console to make sure you have the values you think you do. You may have noticed that around line 820 you do this:

then a few lines later you do this:

phoneNumber is blank. That's why you are getting that invalid number message.
[ December 02, 2003: Message edited by: Joe Ess ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic