Results 1 to 1 of 1
- 03-30-2011, 05:20 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 10
- Rep Power
- 0
How to keep trying to other machine with exceptional handling
Hi
I am trying to connect to machine in client-server model such that client should keep trying sending request to server until it gets a response from server and not just throw an exception, how can I handle that. Here the thing is that machine P0 may not be put when P1 is trying but will be run in few sec, so I need to keep trying that.
Here's what I am doing
Where P1 wants to keep trying to contact with P0. But it just keeps looping by throwing exceptionsJava Code:while(P1Ack != 1) { P1connectsP0(); } public void P1connectsP0() { message.data[0] = "init"; message.data[1] = pid; try { clientSock = new Socket(lamport.P0Ip, lamport.P0Port); lamport.log(lamport.pid +" ("+lamport.myIp+") "+ " is connecting to P0 ("+ lamport.P0Ip + ")" ); clientWriter = new ObjectOutputStream(clientSock.getOutputStream()); clientReader = new ObjectInputStream(clientSock.getInputStream()); clientWriter.writeObject(message); clientWriter.flush(); } catch(IOException ex) { System.out.println("Error : P1 unable to talk to P0"); ex.printStackTrace(); } }Last edited by Yogesh_P; 03-30-2011 at 05:28 PM.
Similar Threads
-
transfering the file from one machine to another machine using ftp in java
By rkraj in forum Java SoftwareReplies: 0Last Post: 02-07-2011, 01:27 PM -
machine epsilon
By rosh72851 in forum Advanced JavaReplies: 9Last Post: 09-24-2008, 03:16 AM -
machine epsilon
By rosh72851 in forum New To JavaReplies: 2Last Post: 09-23-2008, 10:21 PM -
32 bit machine or 64 bit machine
By Kapil Gupta in forum Advanced JavaReplies: 13Last Post: 06-24-2008, 03:29 AM -
Getting name/ip of a machine
By Java Tip in forum Java TipReplies: 0Last Post: 03-02-2008, 07:11 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks