diff options
author | pjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-11-12 00:53:03 +0000 |
---|---|---|
committer | pjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-11-12 00:53:03 +0000 |
commit | d34b1eeafa3fa94370d9daea349b13b3f1d2046f (patch) | |
tree | 89af770048cabc399c0d028e6dabcf43defd3170 /java/tests/Connection/ClientHandler.java | |
parent | e8d6c3f71e9fc8d3d58e7d0e7cacbdd5c9737753 (diff) | |
download | ATCD-d34b1eeafa3fa94370d9daea349b13b3f1d2046f.tar.gz |
image files
test files
source files
Diffstat (limited to 'java/tests/Connection/ClientHandler.java')
-rw-r--r-- | java/tests/Connection/ClientHandler.java | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/java/tests/Connection/ClientHandler.java b/java/tests/Connection/ClientHandler.java new file mode 100644 index 00000000000..cb2bde1df85 --- /dev/null +++ b/java/tests/Connection/ClientHandler.java @@ -0,0 +1,76 @@ +// ============================================================================ +// +// = PACKAGE +// tests.Connection +// +// = FILENAME +// ClientHandler.java +// +// = AUTHOR +// Prashant Jain +// +// ============================================================================ +package tests.Connection; + +import java.io.*; +import java.net.*; +import ACE.OS.*; +import ACE.Connection.*; + +public class ClientHandler extends SvcHandler +{ + public ClientHandler () + { + } + + public int open (Object obj) + { + new Thread (this).start (); + return 0; + } + + public void run () + { + DataInputStream in = new DataInputStream (System.in); + String msg; + StringBuffer ack = new StringBuffer (); + int ack_len; + try + { + while (true) + { + System.out.print ("Enter input: "); + System.out.flush (); + msg = in.readLine (); + if (msg == null) + break; + this.peer ().send (new StringBuffer (msg)); + System.out.println ("Waiting for ack..."); + ack_len = this.peer ().recv (ack); + if (ack_len == 0) + break; + else + System.out.println (ack); + } + } + catch (NullPointerException e) + { + ACE.ERROR ("connection reset by peer"); + } + catch (IOException e) + { + ACE.ERROR (e); + } + finally + { + try + { + this.peer ().close (); + } + catch (IOException e) + { + } + } + + } +} |