@Experimental public class SocketInfo extends Object
SocketSource.
NOTE: The stored address may differ from the one in socket.getRemoteSocketAddress(),
see getSocketAddress() docs.
SocketInfo instance provides direct access to input/output
streams of the associated socket.
Code using the provided SocketInfo as a standard socket replacement should use these IO streams directly,
because the future implementations can substitute some alternative streams if needed.
| Modifier and Type | Field and Description |
|---|---|
protected Socket |
socket |
protected SocketAddress |
socketAddress |
| Constructor and Description |
|---|
SocketInfo(Socket socket,
SocketAddress socketAddress)
Constructs a new instance of
SocketInfo with the provided socket and socket address. |
| Modifier and Type | Method and Description |
|---|---|
InputStream |
getInputStream()
Returns an input stream that reads from the socket.
|
OutputStream |
getOutputStream()
Returns an output stream that writes to the socket.
|
Socket |
getSocket()
Gets the
Socket . |
SocketAddress |
getSocketAddress()
Gets the socket address.
|
String |
toString() |
protected final Socket socket
protected final SocketAddress socketAddress
public SocketInfo(Socket socket, SocketAddress socketAddress)
SocketInfo with the provided socket and socket address.socket - the Socket instance representing the network socket.socketAddress - the SocketAddress instance representing the address of the socket.public Socket getSocket()
Socket .Socket instance representing the underlying network connection.public SocketAddress getSocketAddress()
This address represents the target address of the connection evaluated by the SocketInfo provider and may
differ from the remote address of the socket.
For example, in case the socket is connected via HTTPS proxy, it would be the real destination address rather
than a proxy address.
SocketAddresspublic InputStream getInputStream() throws IOException
IOException - if an I/O error occurs when creating the input stream.public OutputStream getOutputStream() throws IOException
IOException - if an I/O error occurs when creating the output stream.Copyright © 2002–2026 Devexperts LLC. All rights reserved.