java.lang.Object | |
↳ | java.net.SocketImpl |
This class is the base of all streaming socket implementation classes.
Streaming sockets are wrapped by two classes, ServerSocket
and
Socket
at the server and client end of a connection. At the server,
there are two types of sockets engaged in communication, the ServerSocket
on a well known port (referred to as listener) used to
establish a connection and the resulting Socket
(referred to as
host).
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
java.net.SocketOptions
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
address | The remote address this socket is connected to. | ||||||||||
fd | The file descriptor of this socket. | ||||||||||
localport | The local port this socket is connected to. | ||||||||||
port | The remote port this socket is connected to. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a string containing a concise, human-readable description of the
socket.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Waits for an incoming request and blocks until the connection is opened
on the given socket.
| |||||||||||
Returns the available number of bytes which are readable from this socket
without blocking.
| |||||||||||
Binds this socket to the specified local host address and port number.
| |||||||||||
Closes this socket.
| |||||||||||
Connects this socket to the specified remote host address and port
number.
| |||||||||||
Connects this socket to the remote host address and port number specified
by the
SocketAddress object with the given timeout.
| |||||||||||
Connects this socket to the specified remote host and port number.
| |||||||||||
Creates a new unconnected socket.
| |||||||||||
Gets the file descriptor of this socket.
| |||||||||||
Gets the remote address this socket is connected to.
| |||||||||||
Gets the input stream of this socket.
| |||||||||||
Gets the local port number of this socket.
| |||||||||||
Gets the output stream of this socket.
| |||||||||||
Gets the remote port number of this socket.
| |||||||||||
Listens for connection requests on this streaming socket.
| |||||||||||
Sends the single byte of urgent data on the socket.
| |||||||||||
Sets performance preference for connection time, latency and bandwidth.
| |||||||||||
Closes the input channel of this socket.
| |||||||||||
Closes the output channel of this socket.
| |||||||||||
Returns whether the socket supports urgent data or not.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.net.SocketOptions
|
Returns a string containing a concise, human-readable description of the socket.
Waits for an incoming request and blocks until the connection is opened on the given socket.
newSocket | the socket to accept connections on. |
---|
IOException | if an error occurs while accepting a new connection. |
---|
Returns the available number of bytes which are readable from this socket without blocking.
IOException | if an error occurs while reading the number of bytes. |
---|
Binds this socket to the specified local host address and port number.
address | the local machine address to bind this socket to. |
---|---|
port | the port on the local machine to bind this socket to. |
IOException | if an error occurs while binding this socket. |
---|
Closes this socket. This makes later access invalid.
IOException | if an error occurs while closing this socket. |
---|
Connects this socket to the specified remote host address and port number.
address | the remote host address this socket has to be connected to. |
---|---|
port | the remote port on which this socket has to be connected. |
IOException | if an error occurs while connecting to the remote host. |
---|
Connects this socket to the remote host address and port number specified
by the SocketAddress
object with the given timeout. This method
will block indefinitely if the timeout is set to zero.
remoteAddr | the remote host address and port number to connect to. |
---|---|
timeout | the timeout value in milliseconds. |
IOException | if an error occurs while connecting. |
---|
Connects this socket to the specified remote host and port number.
host | the remote host this socket has to be connected to. |
---|---|
port | the remote port on which this socket has to be connected. |
IOException | if an error occurs while connecting to the remote host. |
---|
Creates a new unconnected socket. The argument isStreaming
defines whether the new socket is a streaming or a datagram socket.
isStreaming | defines whether the type of the new socket is streaming or datagram. |
---|
IOException | if an error occurs while creating the socket. |
---|
Gets the file descriptor of this socket.
Gets the remote address this socket is connected to.
Gets the input stream of this socket.
IOException | if an error occurs while accessing the input stream. |
---|
Gets the local port number of this socket. 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.
Gets the output stream of this socket.
IOException | if an error occurs while accessing the output stream. |
---|
Gets the remote port number of this socket. This value is not meaningful
when this instance is wrapped by a ServerSocket
.
Listens for connection requests on this streaming socket. Incoming
connection requests are queued up to the limit specified by backlog
. Additional requests are rejected. This method
may only be invoked on stream sockets.
backlog | the maximum number of outstanding connection requests. |
---|
IOException | if an error occurs while listening. |
---|
Sends the single byte of urgent data on the socket.
value | the byte of urgent data. |
---|
IOException | if an error occurs sending urgent data. |
---|
Sets performance preference for connection time, latency and bandwidth. Does nothing by default.
connectionTime | the importance of connect time. |
---|---|
latency | the importance of latency. |
bandwidth | the importance of bandwidth. |
Closes the input channel of this socket.
This default implementation always throws an IOException
to
indicate that the subclass should have overridden this method.
IOException | always because this method should be overridden. |
---|
Closes the output channel of this socket.
This default implementation always throws an IOException
to
indicate that the subclass should have overridden this method.
IOException | always because this method should be overridden. |
---|
Returns whether the socket supports urgent data or not. Subclasses should override this method.
false
because subclasses must override this method.