1 package com.ubermq.kernel; 2 3 import java.net.*; 4 import java.nio.channels.*; 5 import sun.security.krb5.internal.crypto.*; 6 7 8 16 public class SocketChannelConnectionInfo 17 extends ConnectionInfo 18 implements SocketConnectionInfo 19 { 20 private SocketChannel sc; 21 private String remote; 22 23 public SocketChannelConnectionInfo(SocketChannel channel, 24 IDatagramFactory f, 25 IMessageProcessor proc) 26 { 27 super(proc, f); 28 this.sc = channel; 29 attach(sc, sc); 30 31 this.remote = sc.socket().getRemoteSocketAddress().toString(); 33 } 34 35 public Socket getSocket() 36 { 37 return getSocketChannel().socket(); 38 } 39 40 public SocketChannel getSocketChannel() 41 { 42 return sc; 43 } 44 45 public String toString() 46 { 47 return super.getId() + "[remote=" + remote + "]"; 48 } 49 50 public void close() 51 { 52 super.close(); 53 try 54 { 55 sc.socket().shutdownOutput(); 56 sc.socket().shutdownInput(); 57 sc.socket().close(); 58 } 59 catch (java.io.IOException e) {} 60 } 61 } 62 | Popular Tags |