KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ubermq > kernel > PlainSocketConnectionInfo


1 /*
2  * Copyright (c) 2004 Rhombus Technologies, Inc.
3  * All rights reserved.
4  */

5 package com.ubermq.kernel;
6
7 import java.net.*;
8 import java.nio.channels.*;
9
10 /**
11  * A plain socket connection. Such a connection does not use NIO.
12  */

13 public class PlainSocketConnectionInfo
14     extends ConnectionInfo
15     implements SocketConnectionInfo
16 {
17     private Socket socket;
18     private String JavaDoc remote;
19
20     /**
21      *
22      */

23     public PlainSocketConnectionInfo(Socket socket,
24                                     IDatagramFactory f,
25                                     IMessageProcessor proc)
26     {
27         super(proc, f);
28         this.socket = socket;
29
30         // get the remote address
31
this.remote = socket.getRemoteSocketAddress().toString();
32     }
33     
34     public Socket getSocket()
35     {
36         return socket;
37     }
38     
39     public String JavaDoc toString()
40     {
41         return super.getId() + "[remote=" + remote + "]";
42     }
43
44     public void close()
45     {
46         super.close();
47         try
48         {
49             socket.shutdownOutput();
50             socket.shutdownInput();
51             socket.close();
52         }
53         catch (java.io.IOException JavaDoc e) {/*we are closing anyway*/}
54     }
55 }
56
Popular Tags