Top Description Fields Constructors Methods
com.sun.mail.util

public Class WriteTimeoutSocket

Additional top-level class in compilation unit: TimeoutOutputStream.

extends Socket
Class Inheritance
Imports
java.io.*, java.net.*, java.util.concurrent.*, java.util.Collections, .Set, java.nio.channels.SocketChannel, java.lang.reflect.*

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

Field Summary

Modifier and TypeField and Description
private final ScheduledExecutorService
private final Socket
private final int

Constructor Summary

AccessConstructor and Description
public
WriteTimeoutSocket(Socket socket, int timeout)

public
WriteTimeoutSocket(int timeout)

public
WriteTimeoutSocket(InetAddress address, int port, int timeout)

public
WriteTimeoutSocket(InetAddress address, int port, InetAddress localAddress, int localPort, int timeout)

public
WriteTimeoutSocket(String host, int port, int timeout)

public
WriteTimeoutSocket(String host, int port, InetAddress localAddress, int localPort, int timeout)

Method Summary

Modifier and TypeMethod and Description
public void
bind(SocketAddress
the SocketAddress to bind to
local
)

Overrides java.net.Socket.bind.

Binds the socket to a local address.
public void
close()

Overrides java.net.Socket.close.

Implements java.io.Closeable.close.

Closes this socket.
public void
connect(SocketAddress
the SocketAddress
remote
)

Overrides java.net.Socket.connect.

Connects this socket to the server.
public void
connect(SocketAddress
the SocketAddress
remote
,
int
the timeout value to be used in milliseconds.
timeout
)

Overrides java.net.Socket.connect.

Connects this socket to the server with a specified timeout value.
public SocketChannel
getChannel()

Overrides java.net.Socket.getChannel.

Returns the unique SocketChannel object associated with this socket, if any.
public FileDescriptor

Returns:

the FileDescriptor object
getFileDescriptor$
()

KLUDGE for Android, which has this illegal non-Java Compatible method.

public InetAddress
getInetAddress()

Overrides java.net.Socket.getInetAddress.

Returns the address to which the socket is connected.
public InputStream
getInputStream()

Overrides java.net.Socket.getInputStream.

Returns an input stream for this socket.
public boolean
getKeepAlive()

Overrides java.net.Socket.getKeepAlive.

Tests if SO_KEEPALIVE is enabled.
public InetAddress
getLocalAddress()

Overrides java.net.Socket.getLocalAddress.

Gets the local address to which the socket is bound.
public int
getLocalPort()

Overrides java.net.Socket.getLocalPort.

Returns the local port number to which this socket is bound.
public SocketAddress
getLocalSocketAddress()

Overrides java.net.Socket.getLocalSocketAddress.

Returns the address of the endpoint this socket is bound to.
public boolean
getOOBInline()

Overrides java.net.Socket.getOOBInline.

Tests if SO_OOBINLINE is enabled.
public <T> T
getOption(SocketOption<T>
The socket option
so
)

Overrides java.net.Socket.getOption.

Returns the value of a socket option.
public synchronized OutputStream
getOutputStream()

Overrides java.net.Socket.getOutputStream.

Returns an output stream for this socket.
public int
getPort()

Overrides java.net.Socket.getPort.

Returns the remote port number to which this socket is connected.
public int
getReceiveBufferSize()

Overrides java.net.Socket.getReceiveBufferSize.

Gets the value of the SO_RCVBUF option for this Socket, that is the buffer size used by the platform for input on this Socket.
public SocketAddress
getRemoteSocketAddress()

Overrides java.net.Socket.getRemoteSocketAddress.

Returns the address of the endpoint this socket is connected to, or null if it is unconnected.
public boolean
public int
getSendBufferSize()

Overrides java.net.Socket.getSendBufferSize.

Get value of the SO_SNDBUF option for this Socket, that is the buffer size used by the platform for output on this Socket.
public int
getSoLinger()

Overrides java.net.Socket.getSoLinger.

Returns setting for SO_LINGER.
public int
getSoTimeout()

Overrides java.net.Socket.getSoTimeout.

Returns setting for SO_TIMEOUT.
public boolean
getTcpNoDelay()

Overrides java.net.Socket.getTcpNoDelay.

Tests if TCP_NODELAY is enabled.
public int
getTrafficClass()

Overrides java.net.Socket.getTrafficClass.

Gets traffic class or type-of-service in the IP header for packets sent from this Socket

As the underlying network implementation may ignore the traffic class or type-of-service set using setTrafficClass(int) this method may return a different value than was previously set using the setTrafficClass(int) method on this Socket.

public boolean
isBound()

Overrides java.net.Socket.isBound.

Returns the binding state of the socket.
public boolean
isClosed()

Overrides java.net.Socket.isClosed.

Returns the closed state of the socket.
public boolean
isConnected()

Overrides java.net.Socket.isConnected.

Returns the connection state of the socket.
public boolean
isInputShutdown()

Overrides java.net.Socket.isInputShutdown.

Returns whether the read-half of the socket connection is closed.
public boolean
isOutputShutdown()

Overrides java.net.Socket.isOutputShutdown.

Returns whether the write-half of the socket connection is closed.
public void
sendUrgentData(int
The byte of data to send
data
)

Overrides java.net.Socket.sendUrgentData.

Send one byte of urgent data on the socket.
public void
setKeepAlive(boolean
whether or not to have socket keep alive turned on.
on
)

Overrides java.net.Socket.setKeepAlive.

Enable/disable SO_KEEPALIVE.
public void
setOOBInline(boolean
true to enable SO_OOBINLINE, false to disable.
on
)

Overrides java.net.Socket.setOOBInline.

Enable/disable SO_OOBINLINE (receipt of TCP urgent data) By default, this option is disabled and TCP urgent data received on a socket is silently discarded.
public <T> Socket
setOption(SocketOption<T>
The socket option
so
,
T
The value of the socket option. A value of null may be valid for some options.
val
)

Overrides java.net.Socket.setOption.

Sets the value of a socket option.
public void
setPerformancePreferences(int
An int expressing the relative importance of a short connection time
connectionTime
,
int
An int expressing the relative importance of low latency
latency
,
int
An int expressing the relative importance of high bandwidth
bandwidth
)

Overrides java.net.Socket.setPerformancePreferences.

Sets performance preferences for this socket.
public void
setReceiveBufferSize(int
the size to which to set the receive buffer size. This value must be greater than 0.
size
)

Overrides java.net.Socket.setReceiveBufferSize.

Sets the SO_RCVBUF option to the specified value for this Socket.
public void
setReuseAddress(boolean
whether to enable or disable the socket option
on
)

Overrides java.net.Socket.setReuseAddress.

Enable/disable the SO_REUSEADDR socket option.
public void
setSendBufferSize(int
the size to which to set the send buffer size. This value must be greater than 0.
size
)

Overrides java.net.Socket.setSendBufferSize.

Sets the SO_SNDBUF option to the specified value for this Socket.
public void
setSoLinger(boolean
whether or not to linger on.
on
,
int
how long to linger for, if on is true.
linger
)

Overrides java.net.Socket.setSoLinger.

Enable/disable SO_LINGER with the specified linger time in seconds.
public void
setSoTimeout(int
the specified timeout, in milliseconds.
timeout
)

Overrides java.net.Socket.setSoTimeout.

Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
public void
setTcpNoDelay(boolean
true to enable TCP_NODELAY, false to disable.
on
)

Overrides java.net.Socket.setTcpNoDelay.

Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).
public void
setTrafficClass(int
an int value for the bitset.
tc
)

Overrides java.net.Socket.setTrafficClass.

Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket.
public void
shutdownInput()

Overrides java.net.Socket.shutdownInput.

Places the input stream for this socket at "end of stream".
public void
shutdownOutput()

Overrides java.net.Socket.shutdownOutput.

Disables the output stream for this socket.
public Set<SocketOption<?>>
supportedOptions()

Overrides java.net.Socket.supportedOptions.

Returns a set of the socket options supported by this socket.
public String
toString()

Overrides java.net.Socket.toString.

Converts this socket to a String.
Inherited from java.net.Socket:
setSocketImplFactory