File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Client server help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Client server help" Watch "Client server help" New topic

Client server help

jon ladd
Ranch Hand

Joined: Feb 11, 2003
Posts: 53
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

Joined: Oct 29, 2001
Posts: 9189

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 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 ]

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: Client server help
It's not a secret anymore!