1 28 29 package com.caucho.server.connection; 30 31 import com.caucho.vfs.ReadStream; 32 import com.caucho.vfs.WriteStream; 33 34 import java.net.InetAddress ; 35 36 44 public abstract class Connection { 45 private final ReadStream _readStream; 46 private final WriteStream _writeStream; 47 48 public Connection() 49 { 50 _readStream = new ReadStream(); 51 _readStream.setReuseBuffer(true); 52 _writeStream = new WriteStream(); 53 _writeStream.setReuseBuffer(true); 54 } 55 56 59 abstract public int getId(); 60 61 66 public final ReadStream getReadStream() 67 { 68 return _readStream; 69 } 70 71 76 public final WriteStream getWriteStream() 77 { 78 return _writeStream; 79 } 80 81 84 public boolean isSecure() 85 { 86 return false; 87 } 88 91 public String getVirtualHost() 92 { 93 return null; 94 } 95 98 public abstract InetAddress getLocalAddress(); 99 100 103 public abstract int getLocalPort(); 104 105 108 public abstract InetAddress getRemoteAddress(); 109 110 113 public String getRemoteHost() 114 { 115 return getRemoteAddress().getHostAddress(); 116 } 117 118 121 public int getRemoteAddress(byte []buffer, int offset, int length) 122 { 123 InetAddress remote = getRemoteAddress(); 124 String name = remote.getHostAddress(); 125 int len = name.length(); 126 127 for (int i = 0; i < len; i++) 128 buffer[offset + i] = (byte) name.charAt(i); 129 130 return len; 131 } 132 133 136 public abstract int getRemotePort(); 137 138 141 public void sendBroadcast(BroadcastTask task) 142 { 143 } 144 } 145 | Popular Tags |