Package com.sun.mail.util
Class WriteTimeoutSocket
- 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.SocketA special Socket that uses a ScheduledExecutorService to implement timeouts for writes. The write timeout is specified (in milliseconds) when the WriteTimeoutSocket is created.
-
-
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 voidbind(java.net.SocketAddress local)voidclose()voidconnect(java.net.SocketAddress remote)voidconnect(java.net.SocketAddress remote, int timeout)java.nio.channels.SocketChannelgetChannel()java.io.FileDescriptorgetFileDescriptor$()KLUDGE for Android, which has this illegal non-Java Compatible method.java.net.InetAddressgetInetAddress()java.io.InputStreamgetInputStream()booleangetKeepAlive()java.net.InetAddressgetLocalAddress()intgetLocalPort()java.net.SocketAddressgetLocalSocketAddress()booleangetOOBInline()<T> TgetOption(java.net.SocketOption<T> so)java.io.OutputStreamgetOutputStream()intgetPort()intgetReceiveBufferSize()java.net.SocketAddressgetRemoteSocketAddress()booleangetReuseAddress()intgetSendBufferSize()intgetSoLinger()intgetSoTimeout()booleangetTcpNoDelay()intgetTrafficClass()booleanisBound()booleanisClosed()booleanisConnected()booleanisInputShutdown()booleanisOutputShutdown()voidsendUrgentData(int data)voidsetKeepAlive(boolean on)voidsetOOBInline(boolean on)<T> java.net.SocketsetOption(java.net.SocketOption<T> so, T val)voidsetPerformancePreferences(int connectionTime, int latency, int bandwidth)voidsetReceiveBufferSize(int size)voidsetReuseAddress(boolean on)voidsetSendBufferSize(int size)voidsetSoLinger(boolean on, int linger)voidsetSoTimeout(int timeout)voidsetTcpNoDelay(boolean on)voidsetTrafficClass(int tc)voidshutdownInput()voidshutdownOutput()java.util.Set<java.net.SocketOption<?>>supportedOptions()java.lang.StringtoString()
-
-
-
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:
connectin classjava.net.Socket- Throws:
java.io.IOException
-
connect
public void connect(java.net.SocketAddress remote, int timeout) throws java.io.IOException- Overrides:
connectin classjava.net.Socket- Throws:
java.io.IOException
-
bind
public void bind(java.net.SocketAddress local) throws java.io.IOException- Overrides:
bindin classjava.net.Socket- Throws:
java.io.IOException
-
getRemoteSocketAddress
public java.net.SocketAddress getRemoteSocketAddress()
- Overrides:
getRemoteSocketAddressin classjava.net.Socket
-
getLocalSocketAddress
public java.net.SocketAddress getLocalSocketAddress()
- Overrides:
getLocalSocketAddressin classjava.net.Socket
-
setPerformancePreferences
public void setPerformancePreferences(int connectionTime, int latency, int bandwidth)- Overrides:
setPerformancePreferencesin classjava.net.Socket
-
getChannel
public java.nio.channels.SocketChannel getChannel()
- Overrides:
getChannelin classjava.net.Socket
-
getInetAddress
public java.net.InetAddress getInetAddress()
- Overrides:
getInetAddressin classjava.net.Socket
-
getLocalAddress
public java.net.InetAddress getLocalAddress()
- Overrides:
getLocalAddressin classjava.net.Socket
-
getPort
public int getPort()
- Overrides:
getPortin classjava.net.Socket
-
getLocalPort
public int getLocalPort()
- Overrides:
getLocalPortin classjava.net.Socket
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException- Overrides:
getInputStreamin classjava.net.Socket- Throws:
java.io.IOException
-
getOutputStream
public java.io.OutputStream getOutputStream() throws java.io.IOException- Overrides:
getOutputStreamin classjava.net.Socket- Throws:
java.io.IOException
-
setTcpNoDelay
public void setTcpNoDelay(boolean on) throws java.net.SocketException- Overrides:
setTcpNoDelayin classjava.net.Socket- Throws:
java.net.SocketException
-
getTcpNoDelay
public boolean getTcpNoDelay() throws java.net.SocketException- Overrides:
getTcpNoDelayin classjava.net.Socket- Throws:
java.net.SocketException
-
setSoLinger
public void setSoLinger(boolean on, int linger) throws java.net.SocketException- Overrides:
setSoLingerin classjava.net.Socket- Throws:
java.net.SocketException
-
getSoLinger
public int getSoLinger() throws java.net.SocketException- Overrides:
getSoLingerin classjava.net.Socket- Throws:
java.net.SocketException
-
sendUrgentData
public void sendUrgentData(int data) throws java.io.IOException- Overrides:
sendUrgentDatain classjava.net.Socket- Throws:
java.io.IOException
-
setOOBInline
public void setOOBInline(boolean on) throws java.net.SocketException- Overrides:
setOOBInlinein classjava.net.Socket- Throws:
java.net.SocketException
-
getOOBInline
public boolean getOOBInline() throws java.net.SocketException- Overrides:
getOOBInlinein classjava.net.Socket- Throws:
java.net.SocketException
-
setSoTimeout
public void setSoTimeout(int timeout) throws java.net.SocketException- Overrides:
setSoTimeoutin classjava.net.Socket- Throws:
java.net.SocketException
-
getSoTimeout
public int getSoTimeout() throws java.net.SocketException- Overrides:
getSoTimeoutin classjava.net.Socket- Throws:
java.net.SocketException
-
setSendBufferSize
public void setSendBufferSize(int size) throws java.net.SocketException- Overrides:
setSendBufferSizein classjava.net.Socket- Throws:
java.net.SocketException
-
getSendBufferSize
public int getSendBufferSize() throws java.net.SocketException- Overrides:
getSendBufferSizein classjava.net.Socket- Throws:
java.net.SocketException
-
setReceiveBufferSize
public void setReceiveBufferSize(int size) throws java.net.SocketException- Overrides:
setReceiveBufferSizein classjava.net.Socket- Throws:
java.net.SocketException
-
getReceiveBufferSize
public int getReceiveBufferSize() throws java.net.SocketException- Overrides:
getReceiveBufferSizein classjava.net.Socket- Throws:
java.net.SocketException
-
setKeepAlive
public void setKeepAlive(boolean on) throws java.net.SocketException- Overrides:
setKeepAlivein classjava.net.Socket- Throws:
java.net.SocketException
-
getKeepAlive
public boolean getKeepAlive() throws java.net.SocketException- Overrides:
getKeepAlivein classjava.net.Socket- Throws:
java.net.SocketException
-
setTrafficClass
public void setTrafficClass(int tc) throws java.net.SocketException- Overrides:
setTrafficClassin classjava.net.Socket- Throws:
java.net.SocketException
-
getTrafficClass
public int getTrafficClass() throws java.net.SocketException- Overrides:
getTrafficClassin classjava.net.Socket- Throws:
java.net.SocketException
-
setReuseAddress
public void setReuseAddress(boolean on) throws java.net.SocketException- Overrides:
setReuseAddressin classjava.net.Socket- Throws:
java.net.SocketException
-
getReuseAddress
public boolean getReuseAddress() throws java.net.SocketException- Overrides:
getReuseAddressin classjava.net.Socket- Throws:
java.net.SocketException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.net.Socket- Throws:
java.io.IOException
-
shutdownInput
public void shutdownInput() throws java.io.IOException- Overrides:
shutdownInputin classjava.net.Socket- Throws:
java.io.IOException
-
shutdownOutput
public void shutdownOutput() throws java.io.IOException- Overrides:
shutdownOutputin classjava.net.Socket- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.net.Socket
-
isConnected
public boolean isConnected()
- Overrides:
isConnectedin classjava.net.Socket
-
isBound
public boolean isBound()
- Overrides:
isBoundin classjava.net.Socket
-
isClosed
public boolean isClosed()
- Overrides:
isClosedin classjava.net.Socket
-
isInputShutdown
public boolean isInputShutdown()
- Overrides:
isInputShutdownin classjava.net.Socket
-
isOutputShutdown
public boolean isOutputShutdown()
- Overrides:
isOutputShutdownin classjava.net.Socket
-
setOption
public <T> java.net.Socket setOption(java.net.SocketOption<T> so, T val) throws java.io.IOException- Overrides:
setOptionin classjava.net.Socket- Throws:
java.io.IOException
-
getOption
public <T> T getOption(java.net.SocketOption<T> so) throws java.io.IOException- Overrides:
getOptionin classjava.net.Socket- Throws:
java.io.IOException
-
supportedOptions
public java.util.Set<java.net.SocketOption<?>> supportedOptions()
- Overrides:
supportedOptionsin classjava.net.Socket
-
getFileDescriptor$
public java.io.FileDescriptor getFileDescriptor$()
KLUDGE for Android, which has this illegal non-Java Compatible method.- Returns:
- the FileDescriptor object
-
-