Class BrokeredSocket
java.lang.Object
java.net.Socket
com.exceptionfactory.socketbroker.BrokeredSocket
- All Implemented Interfaces:
Closeable
,AutoCloseable
Brokered Socket encapsulates Proxy Socket connectivity and provides access to connected Socket properties
-
Constructor Summary
ConstructorDescriptionBrokeredSocket
(BrokerConfiguration brokerConfiguration, SocketBroker socketBroker, SocketFactory socketFactory) Brokered Socket constructor with proxy server address and configured socket broker for handling connection -
Method Summary
Modifier and TypeMethodDescriptionvoid
bind
(SocketAddress localAddress) Bind Proxy Socket to local addressvoid
close()
void
connect
(SocketAddress remoteAddress) Connect to remote address using configured Proxy Server without timeout specifiedvoid
connect
(SocketAddress remoteAddress, int timeout) Connect to remote address using configured Proxy Server with connect timeout specifiedGet Remote Address of connected endpoint through proxy serverboolean
int
boolean
int
getPort()
Get Port of connected Remote Socket Addressint
Get Remote Socket Address based on connected endpoint through proxy serverboolean
int
int
int
boolean
int
boolean
isBound()
boolean
isClosed()
boolean
boolean
boolean
void
sendUrgentData
(int data) void
setKeepAlive
(boolean keepAlive) void
setOOBInline
(boolean oobInline) void
setPerformancePreferences
(int connectionTime, int latency, int bandwidth) void
setReceiveBufferSize
(int receiveBufferSize) void
setReuseAddress
(boolean reuseAddress) void
setSendBufferSize
(int sendBufferSize) void
setSoLinger
(boolean soLinger, int linger) void
setSoTimeout
(int timeout) void
setTcpNoDelay
(boolean tcpNoDelay) void
setTrafficClass
(int trafficClass) void
void
toString()
Methods inherited from class java.net.Socket
setSocketImplFactory
-
Constructor Details
-
BrokeredSocket
public BrokeredSocket(BrokerConfiguration brokerConfiguration, SocketBroker socketBroker, SocketFactory socketFactory) throws IOException Brokered Socket constructor with proxy server address and configured socket broker for handling connection- Parameters:
brokerConfiguration
- Broker ConfigurationsocketBroker
- Socket BrokersocketFactory
- Socket Factory creates Socket used for connecting to Proxy Server- Throws:
IOException
- Thrown on failure to create Socket using SocketFactory
-
-
Method Details
-
bind
Bind Proxy Socket to local address- Overrides:
bind
in classSocket
- Parameters:
localAddress
- Local Address or null to select an available ephemeral port number- Throws:
IOException
- Thrown on bind failures
-
connect
Connect to remote address using configured Proxy Server without timeout specified- Overrides:
connect
in classSocket
- Parameters:
remoteAddress
- Remote Address of connection requested through Proxy Server- Throws:
BrokeredConnectException
- Thrown on connection failures
-
connect
Connect to remote address using configured Proxy Server with connect timeout specified- Overrides:
connect
in classSocket
- Parameters:
remoteAddress
- Remote Address of connection requested through Proxy Servertimeout
- Connection timeout to Proxy Server in milliseconds- Throws:
BrokeredConnectException
- Thrown on connection failures
-
getInetAddress
Get Remote Address of connected endpoint through proxy server- Overrides:
getInetAddress
in classSocket
- Returns:
- Remote Address or null when not connected
-
getPort
public int getPort()Get Port of connected Remote Socket Address -
getRemoteSocketAddress
Get Remote Socket Address based on connected endpoint through proxy server- Overrides:
getRemoteSocketAddress
in classSocket
- Returns:
- Remote Socket Address or null when not connected
-
getInputStream
- Overrides:
getInputStream
in classSocket
- Throws:
IOException
-
getOutputStream
- Overrides:
getOutputStream
in classSocket
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classSocket
- Throws:
IOException
-
getChannel
- Overrides:
getChannel
in classSocket
-
getKeepAlive
- Overrides:
getKeepAlive
in classSocket
- Throws:
SocketException
-
getLocalAddress
- Overrides:
getLocalAddress
in classSocket
-
getLocalPort
public int getLocalPort()- Overrides:
getLocalPort
in classSocket
-
getLocalSocketAddress
- Overrides:
getLocalSocketAddress
in classSocket
-
getOOBInline
- Overrides:
getOOBInline
in classSocket
- Throws:
SocketException
-
getReuseAddress
- Overrides:
getReuseAddress
in classSocket
- Throws:
SocketException
-
getReceiveBufferSize
- Overrides:
getReceiveBufferSize
in classSocket
- Throws:
SocketException
-
getSendBufferSize
- Overrides:
getSendBufferSize
in classSocket
- Throws:
SocketException
-
getSoLinger
- Overrides:
getSoLinger
in classSocket
- Throws:
SocketException
-
getSoTimeout
- Overrides:
getSoTimeout
in classSocket
- Throws:
SocketException
-
getTcpNoDelay
- Overrides:
getTcpNoDelay
in classSocket
- Throws:
SocketException
-
getTrafficClass
- Overrides:
getTrafficClass
in classSocket
- Throws:
SocketException
-
isBound
public boolean isBound() -
isClosed
public boolean isClosed() -
isConnected
public boolean isConnected()- Overrides:
isConnected
in classSocket
-
isInputShutdown
public boolean isInputShutdown()- Overrides:
isInputShutdown
in classSocket
-
isOutputShutdown
public boolean isOutputShutdown()- Overrides:
isOutputShutdown
in classSocket
-
sendUrgentData
- Overrides:
sendUrgentData
in classSocket
- Throws:
IOException
-
setKeepAlive
- Overrides:
setKeepAlive
in classSocket
- Throws:
SocketException
-
setOOBInline
- Overrides:
setOOBInline
in classSocket
- Throws:
SocketException
-
setPerformancePreferences
public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) - Overrides:
setPerformancePreferences
in classSocket
-
setReceiveBufferSize
- Overrides:
setReceiveBufferSize
in classSocket
- Throws:
SocketException
-
setReuseAddress
- Overrides:
setReuseAddress
in classSocket
- Throws:
SocketException
-
setSendBufferSize
- Overrides:
setSendBufferSize
in classSocket
- Throws:
SocketException
-
setSoLinger
- Overrides:
setSoLinger
in classSocket
- Throws:
SocketException
-
setSoTimeout
- Overrides:
setSoTimeout
in classSocket
- Throws:
SocketException
-
setTcpNoDelay
- Overrides:
setTcpNoDelay
in classSocket
- Throws:
SocketException
-
setTrafficClass
- Overrides:
setTrafficClass
in classSocket
- Throws:
SocketException
-
shutdownInput
- Overrides:
shutdownInput
in classSocket
- Throws:
IOException
-
shutdownOutput
- Overrides:
shutdownOutput
in classSocket
- Throws:
IOException
-
toString
-