- java.lang.Object
-
- java.net.Socket
-
- com.sun.mail.util.WriteTimeoutSocket
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class WriteTimeoutSocket extends java.net.Socket
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
Constructors Constructor Description WriteTimeoutSocket(int timeout)
WriteTimeoutSocket(java.lang.String host, int port, int timeout)
WriteTimeoutSocket(java.lang.String host, int port, java.net.InetAddress localAddress, int localPort, int timeout)
WriteTimeoutSocket(java.net.InetAddress address, int port, int timeout)
WriteTimeoutSocket(java.net.InetAddress address, int port, java.net.InetAddress localAddress, int localPort, int timeout)
WriteTimeoutSocket(java.net.Socket socket, int timeout)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bind(java.net.SocketAddress local)
void
close()
void
connect(java.net.SocketAddress remote)
void
connect(java.net.SocketAddress remote, int timeout)
java.nio.channels.SocketChannel
getChannel()
java.io.FileDescriptor
getFileDescriptor$()
KLUDGE for Android, which has this illegal non-Java Compatible method.java.net.InetAddress
getInetAddress()
java.io.InputStream
getInputStream()
boolean
getKeepAlive()
java.net.InetAddress
getLocalAddress()
int
getLocalPort()
java.net.SocketAddress
getLocalSocketAddress()
boolean
getOOBInline()
<T> T
getOption(java.net.SocketOption<T> so)
java.io.OutputStream
getOutputStream()
int
getPort()
int
getReceiveBufferSize()
java.net.SocketAddress
getRemoteSocketAddress()
boolean
getReuseAddress()
int
getSendBufferSize()
int
getSoLinger()
int
getSoTimeout()
boolean
getTcpNoDelay()
int
getTrafficClass()
boolean
isBound()
boolean
isClosed()
boolean
isConnected()
boolean
isInputShutdown()
boolean
isOutputShutdown()
void
sendUrgentData(int data)
void
setKeepAlive(boolean on)
void
setOOBInline(boolean on)
<T> java.net.Socket
setOption(java.net.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
shutdownInput()
void
shutdownOutput()
java.util.Set<java.net.SocketOption<?>>
supportedOptions()
java.lang.String
toString()
-
-
-
Constructor Detail
-
WriteTimeoutSocket
public WriteTimeoutSocket(java.net.Socket socket, int timeout) throws java.io.IOException
- Throws:
java.io.IOException
-
WriteTimeoutSocket
public WriteTimeoutSocket(int timeout) throws java.io.IOException
- Throws:
java.io.IOException
-
WriteTimeoutSocket
public WriteTimeoutSocket(java.net.InetAddress address, int port, int timeout) throws java.io.IOException
- Throws:
java.io.IOException
-
WriteTimeoutSocket
public WriteTimeoutSocket(java.net.InetAddress address, int port, java.net.InetAddress localAddress, int localPort, int timeout) throws java.io.IOException
- Throws:
java.io.IOException
-
WriteTimeoutSocket
public WriteTimeoutSocket(java.lang.String host, int port, int timeout) throws java.io.IOException
- Throws:
java.io.IOException
-
WriteTimeoutSocket
public WriteTimeoutSocket(java.lang.String host, int port, java.net.InetAddress localAddress, int localPort, int timeout) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
connect
public void connect(java.net.SocketAddress remote) throws java.io.IOException
- Overrides:
connect
in classjava.net.Socket
- Throws:
java.io.IOException
-
connect
public void connect(java.net.SocketAddress remote, int timeout) throws java.io.IOException
- Overrides:
connect
in classjava.net.Socket
- Throws:
java.io.IOException
-
bind
public void bind(java.net.SocketAddress local) throws java.io.IOException
- Overrides:
bind
in classjava.net.Socket
- Throws:
java.io.IOException
-
getRemoteSocketAddress
public java.net.SocketAddress getRemoteSocketAddress()
- Overrides:
getRemoteSocketAddress
in classjava.net.Socket
-
getLocalSocketAddress
public java.net.SocketAddress getLocalSocketAddress()
- Overrides:
getLocalSocketAddress
in classjava.net.Socket
-
setPerformancePreferences
public void setPerformancePreferences(int connectionTime, int latency, int bandwidth)
- Overrides:
setPerformancePreferences
in classjava.net.Socket
-
getChannel
public java.nio.channels.SocketChannel getChannel()
- Overrides:
getChannel
in classjava.net.Socket
-
getInetAddress
public java.net.InetAddress getInetAddress()
- Overrides:
getInetAddress
in classjava.net.Socket
-
getLocalAddress
public java.net.InetAddress getLocalAddress()
- Overrides:
getLocalAddress
in classjava.net.Socket
-
getPort
public int getPort()
- Overrides:
getPort
in classjava.net.Socket
-
getLocalPort
public int getLocalPort()
- Overrides:
getLocalPort
in classjava.net.Socket
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException
- Overrides:
getInputStream
in classjava.net.Socket
- Throws:
java.io.IOException
-
getOutputStream
public java.io.OutputStream getOutputStream() throws java.io.IOException
- Overrides:
getOutputStream
in classjava.net.Socket
- Throws:
java.io.IOException
-
setTcpNoDelay
public void setTcpNoDelay(boolean on) throws java.net.SocketException
- Overrides:
setTcpNoDelay
in classjava.net.Socket
- Throws:
java.net.SocketException
-
getTcpNoDelay
public boolean getTcpNoDelay() throws java.net.SocketException
- Overrides:
getTcpNoDelay
in classjava.net.Socket
- Throws:
java.net.SocketException
-
setSoLinger
public void setSoLinger(boolean on, int linger) throws java.net.SocketException
- Overrides:
setSoLinger
in classjava.net.Socket
- Throws:
java.net.SocketException
-
getSoLinger
public int getSoLinger() throws java.net.SocketException
- Overrides:
getSoLinger
in classjava.net.Socket
- Throws:
java.net.SocketException
-
sendUrgentData
public void sendUrgentData(int data) throws java.io.IOException
- Overrides:
sendUrgentData
in classjava.net.Socket
- Throws:
java.io.IOException
-
setOOBInline
public void setOOBInline(boolean on) throws java.net.SocketException
- Overrides:
setOOBInline
in classjava.net.Socket
- Throws:
java.net.SocketException
-
getOOBInline
public boolean getOOBInline() throws java.net.SocketException
- Overrides:
getOOBInline
in classjava.net.Socket
- Throws:
java.net.SocketException
-
setSoTimeout
public void setSoTimeout(int timeout) throws java.net.SocketException
- Overrides:
setSoTimeout
in classjava.net.Socket
- Throws:
java.net.SocketException
-
getSoTimeout
public int getSoTimeout() throws java.net.SocketException
- Overrides:
getSoTimeout
in classjava.net.Socket
- Throws:
java.net.SocketException
-
setSendBufferSize
public void setSendBufferSize(int size) throws java.net.SocketException
- Overrides:
setSendBufferSize
in classjava.net.Socket
- Throws:
java.net.SocketException
-
getSendBufferSize
public int getSendBufferSize() throws java.net.SocketException
- Overrides:
getSendBufferSize
in classjava.net.Socket
- Throws:
java.net.SocketException
-
setReceiveBufferSize
public void setReceiveBufferSize(int size) throws java.net.SocketException
- Overrides:
setReceiveBufferSize
in classjava.net.Socket
- Throws:
java.net.SocketException
-
getReceiveBufferSize
public int getReceiveBufferSize() throws java.net.SocketException
- Overrides:
getReceiveBufferSize
in classjava.net.Socket
- Throws:
java.net.SocketException
-
setKeepAlive
public void setKeepAlive(boolean on) throws java.net.SocketException
- Overrides:
setKeepAlive
in classjava.net.Socket
- Throws:
java.net.SocketException
-
getKeepAlive
public boolean getKeepAlive() throws java.net.SocketException
- Overrides:
getKeepAlive
in classjava.net.Socket
- Throws:
java.net.SocketException
-
setTrafficClass
public void setTrafficClass(int tc) throws java.net.SocketException
- Overrides:
setTrafficClass
in classjava.net.Socket
- Throws:
java.net.SocketException
-
getTrafficClass
public int getTrafficClass() throws java.net.SocketException
- Overrides:
getTrafficClass
in classjava.net.Socket
- Throws:
java.net.SocketException
-
setReuseAddress
public void setReuseAddress(boolean on) throws java.net.SocketException
- Overrides:
setReuseAddress
in classjava.net.Socket
- Throws:
java.net.SocketException
-
getReuseAddress
public boolean getReuseAddress() throws java.net.SocketException
- Overrides:
getReuseAddress
in classjava.net.Socket
- Throws:
java.net.SocketException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.net.Socket
- Throws:
java.io.IOException
-
shutdownInput
public void shutdownInput() throws java.io.IOException
- Overrides:
shutdownInput
in classjava.net.Socket
- Throws:
java.io.IOException
-
shutdownOutput
public void shutdownOutput() throws java.io.IOException
- Overrides:
shutdownOutput
in classjava.net.Socket
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.net.Socket
-
isConnected
public boolean isConnected()
- Overrides:
isConnected
in classjava.net.Socket
-
isBound
public boolean isBound()
- Overrides:
isBound
in classjava.net.Socket
-
isClosed
public boolean isClosed()
- Overrides:
isClosed
in classjava.net.Socket
-
isInputShutdown
public boolean isInputShutdown()
- Overrides:
isInputShutdown
in classjava.net.Socket
-
isOutputShutdown
public boolean isOutputShutdown()
- Overrides:
isOutputShutdown
in classjava.net.Socket
-
setOption
public <T> java.net.Socket setOption(java.net.SocketOption<T> so, T val) throws java.io.IOException
- Overrides:
setOption
in classjava.net.Socket
- Throws:
java.io.IOException
-
getOption
public <T> T getOption(java.net.SocketOption<T> so) throws java.io.IOException
- Overrides:
getOption
in classjava.net.Socket
- Throws:
java.io.IOException
-
supportedOptions
public java.util.Set<java.net.SocketOption<?>> supportedOptions()
- Overrides:
supportedOptions
in classjava.net.Socket
-
getFileDescriptor$
public java.io.FileDescriptor getFileDescriptor$()
KLUDGE for Android, which has this illegal non-Java Compatible method.- Returns:
- the FileDescriptor object
-
-