socket problem, how to reconnect without restart

J

John_Woo

Hi,

One machine runs as socket server, talking to other machines (both
sides, socket keep
running, never being closed).

The problem over this communnication is that, whenever a cable
unplugged,
the server app has to be restarted, so the client-machine can get
reconnection again.


the client side code snippet is:

Socket send = new Socket(ip, port);

the exception is
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.ja
at java.net.PlainSocketImpl.connectToAddress(PlainSocket
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java
at java.net.Socket.connect(Socket.java:507)
at java.net.Socket.connect(Socket.java:457)
at java.net.Socket.<init>(Socket.java:365)
at java.net.Socket.<init>(Socket.java:178)

Can any one tell how to fix it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top