java.net
public
abstract
class
java.net.SocketImpl
The abstract superclass of all classes that implement streaming sockets.
Streaming sockets are wrapped by two classes, ServerSocket and Socket at the
server and client end of a connection respectively. At the server there are
two types of sockets engaged in communication, the ServerSocket
on a well known port (hereafter refered to as the listener) used to establish
a connection and the resulting Socket
(hereafter refered to as
host).
Some of the SocketImpl
instance variable values must be
interpreted in the context of the wrapper. See the getter methods for these
details.
Summary
IP_MULTICAST_IF,
IP_MULTICAST_IF2,
IP_MULTICAST_LOOP,
IP_TOS,
SO_BINDADDR,
SO_BROADCAST,
SO_KEEPALIVE,
SO_LINGER,
SO_OOBINLINE,
SO_RCVBUF,
SO_REUSEADDR,
SO_SNDBUF,
SO_TIMEOUT,
TCP_NODELAY
Fields
Public Constructors
Public Methods
Protected Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Fields
protected
int
receiveTimeout
Public Constructors
public
SocketImpl()
Construct a connection-oriented SocketImpl.
Public Methods
public
abstract
Object
getOption(int optID)
Answer the nominated socket option.
Parameters
optID
| the socket option to retrieve |
public
abstract
void
setOption(int optID, Object val)
Set the nominated socket option.
Parameters
optID
| the socket option to set |
val
| the option value |
public
String
toString()
Returns a string containing a concise, human-readable description of the
socket.
Protected Methods
protected
abstract
void
accept(SocketImpl newSocket)
Accepts a connection on the provided socket.
Parameters
newSocket
| the socket to accept connections on |
protected
abstract
int
available()
Answer the number of bytes that may be read from this socket without
blocking. This call does not block.
Returns
- int the number of bytes that may be read without blocking
protected
abstract
void
bind(InetAddress address, int port)
Binds this socket to the specified local host/port.
Parameters
address
| the local machine address to bind the socket to |
port
| the port on the local machine to bind the socket to |
protected
abstract
void
close()
Close the socket. Usage thereafter is invalid.
protected
abstract
void
connect(SocketAddress remoteAddr, int timeout)
Connect the socket to the host/port specified by the SocketAddress with a
specified timeout.
Parameters
remoteAddr
| the remote machine address and port to connect to |
timeout
| the millisecond timeout value, the connect will block
indefinitely for a zero value. |
protected
abstract
void
connect(InetAddress address, int port)
Connects this socket to the specified remote host address/port.
Parameters
address
| the remote host address to connect to |
port
| the remote port to connect to |
protected
abstract
void
connect(String host, int port)
Connects this socket to the specified remote host/port.
Parameters
host
| the remote host to connect to |
port
| the remote port to connect to |
protected
abstract
void
create(boolean isStreaming)
Creates a new unconnected socket. If streaming is true, create a stream
socket, else a datagram socket.
Parameters
isStreaming
| true, if the socket is type streaming |
protected
FileDescriptor
getFileDescriptor()
Answer the socket's file descriptor.
Returns
- FileDescriptor the socket FileDescriptor
protected
InetAddress
getInetAddress()
Answer the socket's address. Refering to the class comment: Listener: The
local machines IP address to which this socket is bound. Host: The client
machine, to which this socket is connected. Client: The host machine, to
which this socket is connected.
Returns
- InetAddress the socket address
protected
abstract
InputStream
getInputStream()
Answer the socket input stream.
Returns
- InputStream an InputStream on the socket
Throws
IOException
| thrown if an error occurs while accessing the stream
|
protected
int
getLocalPort()
Answer the socket's localport. The field is initialized to -1 and upon
demand will go to the IP stack to get the bound value. See the class
comment for the context of the local port.
protected
abstract
OutputStream
getOutputStream()
Answer the socket output stream.
Returns
- OutputStream an OutputStream on the socket
Throws
IOException
| thrown if an error occurs while accessing the stream
|
protected
int
getPort()
Answer the socket's remote port. This value is not meaningful when the
socketImpl is wrapped by a ServerSocket.
Returns
- int the remote port the socket is connected to
protected
abstract
void
listen(int backlog)
Listen for connection requests on this stream socket. Incoming connection
requests are queued, up to the limit nominated by backlog. Additional
requests are rejected. listen() may only be invoked on stream sockets.
Parameters
backlog
| the max number of outstanding connection requests |
protected
abstract
void
sendUrgentData(int value)
Send the single byte of urgent data on the socket.
Parameters
value
| the byte of urgent data |
protected
void
setPerformancePreferences(int connectionTime, int latency, int bandwidth)
Sets performance preference for connectionTime, latency and bandwidth.
Does nothing by default.
Parameters
connectionTime
| the importance of connect time |
latency
| the importance of latency |
bandwidth
| the importance of bandwidth
|
protected
void
shutdownInput()
Shutdown the input portion of the socket.
The default implementation always throws an
IOException
to indicate that the subclass should have overridden this
method.
protected
void
shutdownOutput()
Shutdown the output portion of the socket.
The default implementation always throws an
IOException
to indicate that the subclass should have overridden this
method.
protected
boolean
supportsUrgentData()
Answer if the socket supports urgent data. Subclasses should override
this method.
Returns
- false, subclasses must override