Package com.sun.mail.util
Class WriteTimeoutSocket
java.lang.Object
java.net.Socket
com.sun.mail.util.WriteTimeoutSocket
- All Implemented Interfaces:
Closeable
,AutoCloseable
A special Socket that uses a ScheduledExecutorService to
implement timeouts for writes. The write timeout is specified
(in milliseconds) when the WriteTimeoutSocket is created.
- Author:
- Bill Shannon
-
Constructor Summary
ConstructorsConstructorDescriptionWriteTimeoutSocket
(int timeout) WriteTimeoutSocket
(String host, int port, int timeout) WriteTimeoutSocket
(String host, int port, InetAddress localAddress, int localPort, int timeout) WriteTimeoutSocket
(InetAddress address, int port, int timeout) WriteTimeoutSocket
(InetAddress address, int port, InetAddress localAddress, int localPort, int timeout) WriteTimeoutSocket
(Socket socket, int timeout) -
Method Summary
Modifier and TypeMethodDescriptionvoid
bind
(SocketAddress local) void
close()
void
connect
(SocketAddress remote) void
connect
(SocketAddress remote, int timeout) KLUDGE for Android, which has this illegal non-Java Compatible method.boolean
int
boolean
<T> T
getOption
(SocketOption<T> so) int
getPort()
int
boolean
int
int
int
boolean
int
boolean
isBound()
boolean
isClosed()
boolean
boolean
boolean
void
sendUrgentData
(int data) void
setKeepAlive
(boolean on) void
setOOBInline
(boolean on) <T> Socket
setOption
(SocketOption<T> so, T val) void
setPerformancePreferences
(int connectionTime, int latency, int bandwidth) void
setReceiveBufferSize
(int size) void
setReuseAddress
(boolean on) void
setSendBufferSize
(int size) void
setSoLinger
(boolean on, int linger) void
setSoTimeout
(int timeout) void
setTcpNoDelay
(boolean on) void
setTrafficClass
(int tc) void
void
Set<SocketOption<?>>
toString()
Methods inherited from class java.net.Socket
setSocketImplFactory
-
Constructor Details
-
WriteTimeoutSocket
- Throws:
IOException
-
WriteTimeoutSocket
- Throws:
IOException
-
WriteTimeoutSocket
- Throws:
IOException
-
WriteTimeoutSocket
public WriteTimeoutSocket(InetAddress address, int port, InetAddress localAddress, int localPort, int timeout) throws IOException - Throws:
IOException
-
WriteTimeoutSocket
- Throws:
IOException
-
WriteTimeoutSocket
public WriteTimeoutSocket(String host, int port, InetAddress localAddress, int localPort, int timeout) throws IOException - Throws:
IOException
-
-
Method Details
-
connect
- Overrides:
connect
in classSocket
- Throws:
IOException
-
connect
- Overrides:
connect
in classSocket
- Throws:
IOException
-
bind
- Overrides:
bind
in classSocket
- Throws:
IOException
-
getRemoteSocketAddress
- Overrides:
getRemoteSocketAddress
in classSocket
-
getLocalSocketAddress
- Overrides:
getLocalSocketAddress
in classSocket
-
setPerformancePreferences
public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) - Overrides:
setPerformancePreferences
in classSocket
-
getChannel
- Overrides:
getChannel
in classSocket
-
getInetAddress
- Overrides:
getInetAddress
in classSocket
-
getLocalAddress
- Overrides:
getLocalAddress
in classSocket
-
getPort
public int getPort() -
getLocalPort
public int getLocalPort()- Overrides:
getLocalPort
in classSocket
-
getInputStream
- Overrides:
getInputStream
in classSocket
- Throws:
IOException
-
getOutputStream
- Overrides:
getOutputStream
in classSocket
- Throws:
IOException
-
setTcpNoDelay
- Overrides:
setTcpNoDelay
in classSocket
- Throws:
SocketException
-
getTcpNoDelay
- Overrides:
getTcpNoDelay
in classSocket
- Throws:
SocketException
-
setSoLinger
- Overrides:
setSoLinger
in classSocket
- Throws:
SocketException
-
getSoLinger
- Overrides:
getSoLinger
in classSocket
- Throws:
SocketException
-
sendUrgentData
- Overrides:
sendUrgentData
in classSocket
- Throws:
IOException
-
setOOBInline
- Overrides:
setOOBInline
in classSocket
- Throws:
SocketException
-
getOOBInline
- Overrides:
getOOBInline
in classSocket
- Throws:
SocketException
-
setSoTimeout
- Overrides:
setSoTimeout
in classSocket
- Throws:
SocketException
-
getSoTimeout
- Overrides:
getSoTimeout
in classSocket
- Throws:
SocketException
-
setSendBufferSize
- Overrides:
setSendBufferSize
in classSocket
- Throws:
SocketException
-
getSendBufferSize
- Overrides:
getSendBufferSize
in classSocket
- Throws:
SocketException
-
setReceiveBufferSize
- Overrides:
setReceiveBufferSize
in classSocket
- Throws:
SocketException
-
getReceiveBufferSize
- Overrides:
getReceiveBufferSize
in classSocket
- Throws:
SocketException
-
setKeepAlive
- Overrides:
setKeepAlive
in classSocket
- Throws:
SocketException
-
getKeepAlive
- Overrides:
getKeepAlive
in classSocket
- Throws:
SocketException
-
setTrafficClass
- Overrides:
setTrafficClass
in classSocket
- Throws:
SocketException
-
getTrafficClass
- Overrides:
getTrafficClass
in classSocket
- Throws:
SocketException
-
setReuseAddress
- Overrides:
setReuseAddress
in classSocket
- Throws:
SocketException
-
getReuseAddress
- Overrides:
getReuseAddress
in classSocket
- Throws:
SocketException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classSocket
- Throws:
IOException
-
shutdownInput
- Overrides:
shutdownInput
in classSocket
- Throws:
IOException
-
shutdownOutput
- Overrides:
shutdownOutput
in classSocket
- Throws:
IOException
-
toString
-
isConnected
public boolean isConnected()- Overrides:
isConnected
in classSocket
-
isBound
public boolean isBound() -
isClosed
public boolean isClosed() -
isInputShutdown
public boolean isInputShutdown()- Overrides:
isInputShutdown
in classSocket
-
isOutputShutdown
public boolean isOutputShutdown()- Overrides:
isOutputShutdown
in classSocket
-
setOption
- Overrides:
setOption
in classSocket
- Throws:
IOException
-
getOption
- Overrides:
getOption
in classSocket
- Throws:
IOException
-
supportedOptions
- Overrides:
supportedOptions
in classSocket
-
getFileDescriptor$
KLUDGE for Android, which has this illegal non-Java Compatible method.- Returns:
- the FileDescriptor object
-