MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / SocketEndpoint

Class SocketEndpoint

src/main/java/core/packetproxy/common/SocketEndpoint.java:24–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22import java.net.Socket;
23
24public class SocketEndpoint implements Endpoint {
25
26 Socket socket;
27 InputStream inputstream;
28
29 public SocketEndpoint(Socket socket) throws Exception {
30 this.socket = socket;
31 inputstream = socket.getInputStream();
32 }
33
34 public SocketEndpoint(Socket socket, InputStream lookaheadBuffer) throws Exception {
35 this.socket = socket;
36 inputstream = new SequenceInputStream(lookaheadBuffer, socket.getInputStream());
37 }
38
39 public SocketEndpoint(InetSocketAddress addr) throws Exception {
40 socket = new Socket();
41 socket.connect(addr);
42 inputstream = socket.getInputStream();
43 }
44
45 public SocketEndpoint(InetSocketAddress addr, int timeout) throws Exception {
46 socket = new Socket();
47 socket.connect(addr, timeout);
48 inputstream = socket.getInputStream();
49 }
50
51 @Override
52 public InetSocketAddress getAddress() {
53 return new InetSocketAddress(socket.getInetAddress(), socket.getPort());
54 }
55
56 @Override
57 public InputStream getInputStream() throws Exception {
58 return inputstream;
59 }
60
61 @Override
62 public OutputStream getOutputStream() throws Exception {
63 return socket.getOutputStream();
64 }
65
66 @Override
67 public int getLocalPort() {
68 return socket.getLocalPort();
69 }
70
71 @Override
72 public String getName() {
73 return null;
74 }
75}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected