Top Description Fields Constructors Methods
sun.nio.ch

pack-priv Class DummySocketImpl

extends SocketImpl
Class Inheritance
Imports
java.io.InputStream, .OutputStream, java.net.InetAddress, .SocketAddress, .SocketImpl, .SocketOption, java.util.Set

Dummy SocketImpl for use by the socket adaptors. All methods are overridden to throw an error.

Field Summary

Inherited from java.net.SocketImpl:
addressfdlocalportport

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected void
accept(SocketImpl
the accepted connection.
si
)

Implements abstract java.net.SocketImpl.accept.

Accepts a connection.

protected int
available()

Implements abstract java.net.SocketImpl.available.

Returns the number of bytes that can be read from this socket without blocking.

protected void
bind(InetAddress
an IP address that belongs to a local interface.
host
,
int
the port number.
port
)

Implements abstract java.net.SocketImpl.bind.

Binds this socket to the specified local IP address and port number.

protected void
close()

Implements abstract java.net.SocketImpl.close.

Closes this socket.

protected void
connect(SocketAddress
the Socket address of the remote host.
remote
,
int
the timeout value, in milliseconds, or zero for no timeout.
millis
)

Implements abstract java.net.SocketImpl.connect.

Connects this socket to the specified port number on the specified host.

protected void
connect(String
the name of the remote host.
host
,
int
the port number.
port
)

Implements abstract java.net.SocketImpl.connect.

Connects this socket to the specified port on the named host.

protected void
connect(InetAddress
the IP address of the remote host.
address
,
int
the port number.
port
)

Implements abstract java.net.SocketImpl.connect.

Connects this socket to the specified port number on the specified host.

pack-priv static SocketImpl
protected void
create(boolean
if true, create a stream socket; otherwise, create a datagram socket.
stream
)

Implements abstract java.net.SocketImpl.create.

Creates either a stream or a datagram socket.

protected InputStream
getInputStream()

Implements abstract java.net.SocketImpl.getInputStream.

Returns an input stream for this socket.

protected <T> T
getOption(SocketOption<T>
The socket option
opt
)

Overrides java.net.SocketImpl.getOption.

Called to get a socket option.

public Object
getOption(int
an int identifying the option to fetch
opt
)

Implements java.net.SocketOptions.getOption.

Fetch the value of an option.

protected OutputStream
getOutputStream()

Implements abstract java.net.SocketImpl.getOutputStream.

Returns an output stream for this socket.

protected void
listen(int
the maximum length of the queue.
backlog
)

Implements abstract java.net.SocketImpl.listen.

Sets the maximum queue length for incoming connection indications (a request to connect) to the count argument.

protected void
sendUrgentData(int
The byte of data to send
data
)

Implements abstract java.net.SocketImpl.sendUrgentData.

Send one byte of urgent data on the socket.

protected <T> void
setOption(SocketOption<T>
The socket option
opt
,
T
The value of the socket option. A value of null may be valid for some options.
value
)

Overrides java.net.SocketImpl.setOption.

Called to set a socket option.

public void
setOption(int
identifies the option
opt
,
Object
the parameter of the socket option
value
)

Implements java.net.SocketOptions.setOption.

Enable/disable the option specified by optID.

private static <T> T
protected void
shutdownInput()

Overrides java.net.SocketImpl.shutdownInput.

Places the input stream for this socket at "end of stream".

protected void
shutdownOutput()

Overrides java.net.SocketImpl.shutdownOutput.

Disables the output stream for this socket.

protected Set<SocketOption<?>>
supportedOptions()

Overrides java.net.SocketImpl.supportedOptions.

Returns a set of SocketOptions supported by this impl and by this impl's socket (Socket or ServerSocket)

protected boolean
supportsUrgentData()

Overrides java.net.SocketImpl.supportsUrgentData.

Returns whether or not this SocketImpl supports sending urgent data.

Inherited from java.net.SocketImpl:
getFileDescriptorgetInetAddressgetLocalPortgetPortsetPerformancePreferencestoString

Constructor Detail

DummySocketImplback to summary
private DummySocketImpl()

Method Detail

acceptback to summary
protected void accept(SocketImpl si)

Implements abstract java.net.SocketImpl.accept.

Doc from java.net.SocketImpl.accept.

Accepts a connection.

Parameters
si:SocketImpl

the accepted connection.

Annotations
@Override
availableback to summary
protected int available()

Implements abstract java.net.SocketImpl.available.

Doc from java.net.SocketImpl.available.

Returns the number of bytes that can be read from this socket without blocking.

Returns:int

the number of bytes that can be read from this socket without blocking.

Annotations
@Override
bindback to summary
protected void bind(InetAddress host, int port)

Implements abstract java.net.SocketImpl.bind.

Doc from java.net.SocketImpl.bind.

Binds this socket to the specified local IP address and port number.

Parameters
host:InetAddress

an IP address that belongs to a local interface.

port:int

the port number.

Annotations
@Override
closeback to summary
protected void close()

Implements abstract java.net.SocketImpl.close.

Doc from java.net.SocketImpl.close.

Closes this socket.

Annotations
@Override
connectback to summary
protected void connect(SocketAddress remote, int millis)

Implements abstract java.net.SocketImpl.connect.

Doc from java.net.SocketImpl.connect.

Connects this socket to the specified port number on the specified host. A timeout of zero is interpreted as an infinite timeout. The connection will then block until established or an error occurs.

Parameters
remote:SocketAddress

the Socket address of the remote host.

millis:int

the timeout value, in milliseconds, or zero for no timeout.

Annotations
@Override
connectback to summary
protected void connect(String host, int port)

Implements abstract java.net.SocketImpl.connect.

Doc from java.net.SocketImpl.connect.

Connects this socket to the specified port on the named host.

Parameters
host:String

the name of the remote host.

port:int

the port number.

Annotations
@Override
connectback to summary
protected void connect(InetAddress address, int port)

Implements abstract java.net.SocketImpl.connect.

Doc from java.net.SocketImpl.connect.

Connects this socket to the specified port number on the specified host.

Parameters
address:InetAddress

the IP address of the remote host.

port:int

the port number.

Annotations
@Override
createback to summary
pack-priv static SocketImpl create()
createback to summary
protected void create(boolean stream)

Implements abstract java.net.SocketImpl.create.

Doc from java.net.SocketImpl.create.

Creates either a stream or a datagram socket.

Parameters
stream:boolean

if true, create a stream socket; otherwise, create a datagram socket.

Annotations
@Override
getInputStreamback to summary
protected InputStream getInputStream()

Implements abstract java.net.SocketImpl.getInputStream.

Doc from java.net.SocketImpl.getInputStream.

Returns an input stream for this socket.

Returns:InputStream

a stream for reading from this socket.

Annotations
@Override
getOptionback to summary
protected <T> T getOption(SocketOption<T> opt)

Overrides java.net.SocketImpl.getOption.

Doc from java.net.SocketImpl.getOption.

Called to get a socket option.

Parameters
<T>
The type of the socket option value
opt:SocketOption<T>

The socket option

Returns:T

the value of the named option

Annotations
@Override
getOptionback to summary
public Object getOption(int opt)

Implements java.net.SocketOptions.getOption.

Doc from java.net.SocketOptions.getOption.

Fetch the value of an option. Binary options will return Boolean#TRUE if enabled, Boolean#FALSE if disabled, e.g.:

SocketImpl s; ... Boolean noDelay = (Boolean)(s.getOption(TCP_NODELAY)); if (noDelay.booleanValue()) { // true if TCP_NODELAY is enabled... ... }
SocketImpl s;
...
Boolean noDelay = (Boolean)(s.getOption(TCP_NODELAY));
if (noDelay.booleanValue()) {
    // true if TCP_NODELAY is enabled...
...
}

For options that take a particular type as a parameter, this method will return the parameter's value, else it will return Boolean#FALSE:

Object o = s.getOption(SO_LINGER); if (o instanceof Integer) { System.out.print("Linger time is " + ((Integer)o).intValue()); } else { // the true type of o is java.lang.Boolean.FALSE; }
Object o = s.getOption(SO_LINGER);
if (o instanceof Integer) {
    System.out.print("Linger time is " + ((Integer)o).intValue());
} else {
  // the true type of o is java.lang.Boolean.FALSE;
}
Parameters
opt:int

an int identifying the option to fetch

Returns:Object

the value of the option

Annotations
@Override
getOutputStreamback to summary
protected OutputStream getOutputStream()

Implements abstract java.net.SocketImpl.getOutputStream.

Doc from java.net.SocketImpl.getOutputStream.

Returns an output stream for this socket.

Returns:OutputStream

an output stream for writing to this socket.

Annotations
@Override
listenback to summary
protected void listen(int backlog)

Implements abstract java.net.SocketImpl.listen.

Doc from java.net.SocketImpl.listen.

Sets the maximum queue length for incoming connection indications (a request to connect) to the count argument. If a connection indication arrives when the queue is full, the connection is refused.

Parameters
backlog:int

the maximum length of the queue.

Annotations
@Override
sendUrgentDataback to summary
protected void sendUrgentData(int data)

Implements abstract java.net.SocketImpl.sendUrgentData.

Doc from java.net.SocketImpl.sendUrgentData.

Send one byte of urgent data on the socket. The byte to be sent is the low eight bits of the parameter

Parameters
data:int

The byte of data to send

Annotations
@Override
setOptionback to summary
protected <T> void setOption(SocketOption<T> opt, T value)

Overrides java.net.SocketImpl.setOption.

Doc from java.net.SocketImpl.setOption.

Called to set a socket option.

Parameters
<T>
The type of the socket option value
opt:SocketOption<T>

The socket option

value:T

The value of the socket option. A value of null may be valid for some options.

Annotations
@Override
setOptionback to summary
public void setOption(int opt, Object value)

Implements java.net.SocketOptions.setOption.

Doc from java.net.SocketOptions.setOption.

Enable/disable the option specified by optID. If the option is to be enabled, and it takes an option-specific "value", this is passed in value. The actual type of value is option-specific, and it is an error to pass something that isn't of the expected type:

SocketImpl s; ... s.setOption(SO_LINGER, Integer.valueOf(10)); // OK - set SO_LINGER w/ timeout of 10 sec. s.setOption(SO_LINGER, Double.valueOf(10)); // ERROR - expects java.lang.Integer
SocketImpl s;
...
s.setOption(SO_LINGER, Integer.valueOf(10));
   // OK - set SO_LINGER w/ timeout of 10 sec.
s.setOption(SO_LINGER, Double.valueOf(10));
   // ERROR - expects java.lang.Integer
If the requested option is binary, it can be set using this method by a Boolean:
s.setOption(TCP_NODELAY, Boolean.TRUE); // OK - enables TCP_NODELAY, a binary option
s.setOption(TCP_NODELAY, Boolean.TRUE);
   // OK - enables TCP_NODELAY, a binary option
Any option can be disabled using this method with a Boolean#FALSE:
s.setOption(TCP_NODELAY, Boolean.FALSE); // OK - disables TCP_NODELAY s.setOption(SO_LINGER, Boolean.FALSE); // OK - disables SO_LINGER
s.setOption(TCP_NODELAY, Boolean.FALSE);
   // OK - disables TCP_NODELAY
s.setOption(SO_LINGER, Boolean.FALSE);
   // OK - disables SO_LINGER
For an option that has a notion of on and off, and requires a non-boolean parameter, setting its value to anything other than Boolean#FALSE implicitly enables it.
Parameters
opt:int

identifies the option

value:Object

the parameter of the socket option

Annotations
@Override
shouldNotGetHereback to summary
private static <T> T shouldNotGetHere()
shutdownInputback to summary
protected void shutdownInput()

Overrides java.net.SocketImpl.shutdownInput.

Doc from java.net.SocketImpl.shutdownInput.

Places the input stream for this socket at "end of stream". Any data sent to this socket is acknowledged and then silently discarded. If you read from a socket input stream after invoking this method on the socket, the stream's available method will return 0, and its read methods will return -1 (end of stream).

Annotations
@Override
shutdownOutputback to summary
protected void shutdownOutput()

Overrides java.net.SocketImpl.shutdownOutput.

Doc from java.net.SocketImpl.shutdownOutput.

Disables the output stream for this socket. For a TCP socket, any previously written data will be sent followed by TCP's normal connection termination sequence. If you write to a socket output stream after invoking shutdownOutput() on the socket, the stream will throw an IOException.

Annotations
@Override
supportedOptionsback to summary
protected Set<SocketOption<?>> supportedOptions()

Overrides java.net.SocketImpl.supportedOptions.

Doc from java.net.SocketImpl.supportedOptions.

Returns a set of SocketOptions supported by this impl and by this impl's socket (Socket or ServerSocket)

Returns:Set<SocketOption<?>>

a Set of SocketOptions

Annotations
@Override
supportsUrgentDataback to summary
protected boolean supportsUrgentData()

Overrides java.net.SocketImpl.supportsUrgentData.

Doc from java.net.SocketImpl.supportsUrgentData.

Returns whether or not this SocketImpl supports sending urgent data. By default, false is returned unless the method is overridden in a sub-class

Returns:boolean

true if urgent data supported

Annotations
@Override