aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Server/Client Socket Connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Server/Client Socket Connection" Watch "Server/Client Socket Connection" New topic
Author

Server/Client Socket Connection

Accela Moon
Greenhorn

Joined: Apr 11, 2004
Posts: 20
Hi, I am trying to program a simple server/client socket connection program, the main function is to send and receive objects between them. I somehow went wrong and the connection between them keeps terminating right after establishing connection. Is there anything I can do to resolve this?
This is gonnna be kinda long post.. sorry. These are the code that starts and ends the socket connection. I'm kinda desperate for this to work.. so thanks in advance.
appinterface.java:

Client:
mira yang
Ranch Hand

Joined: Nov 08, 2003
Posts: 33
I got the same problem. And i post a topic in Java � I/O and Streams
If you get a answer,please send a copy to me :miracle-5@163.com
Thanks!
mira yang
Ranch Hand

Joined: Nov 08, 2003
Posts: 33
Hello, I have got a answer to solve this problem:
The best way to create a dead lock is to try to read from both ends of a stream at the same time. I assume that the code for your server and your client are both attempting to get the ObjectInputStream before getting the ObjectOutputStream. Basically, all you have to do to fix this problem is put the getObjectOutputStream line BEFORE the getObjectInputStream line..
Hope this helps!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Server/Client Socket Connection