1 45 46 package org.exolab.jms.net.socket; 47 48 import java.io.IOException ; 49 import java.io.InputStream ; 50 import java.io.OutputStream ; 51 import java.net.Socket ; 52 53 import org.exolab.jms.net.multiplexer.Endpoint; 54 import org.exolab.jms.net.uri.URI; 55 import org.exolab.jms.net.uri.URIHelper; 56 57 58 64 public class SocketEndpoint implements Endpoint { 65 66 69 private final URI _uri; 70 71 74 private Socket _socket; 75 76 79 private InputStream _in; 80 81 84 private OutputStream _out; 85 86 87 94 public SocketEndpoint(String scheme, Socket socket) 95 throws IOException { 96 _uri = URIHelper.create(scheme, 97 socket.getInetAddress().getHostAddress(), 98 socket.getPort()); 99 _socket = socket; 100 _in = socket.getInputStream(); 101 _out = socket.getOutputStream(); 102 } 103 104 109 public URI getURI() { 110 return _uri; 111 } 112 113 118 public InputStream getInputStream() { 119 return _in; 120 } 121 122 127 public OutputStream getOutputStream() { 128 return _out; 129 } 130 131 136 public void close() throws IOException { 137 _socket.close(); 138 } 139 } 140 | Popular Tags |