| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | UnixSocket.
A byte channel that doesn't implement |
| Modifier and Type | Field and Description |
|---|---|
| private UnixSocketChannel | |
| private AtomicBoolean | |
| private InputStream | in
Hides java. |
| private AtomicBoolean | |
| private OutputStream | out
Hides java. |
| private AtomicBoolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | bind(SocketAddress
the local)SocketAddress to bind toOverrides java. |
| public void | |
| public void | connect(SocketAddress
the addr)SocketAddressOverrides java. |
| public void | connect(SocketAddress
the addr, int SocketAddressthe timeout value to be used in milliseconds. timeout)Overrides java. |
| public SocketChannel | getChannel()
Overrides java. SocketChannel
object associated with this socket, if any.
|
| public final Credentials | Returns: the credentials of the remote; null if not connectedRetrieves the credentials for this UNIX socket. |
| public InetAddress | getInetAddress()
Overrides java. |
| public InputStream | |
| public boolean | |
| public SocketAddress | getLocalSocketAddress()
Overrides java. |
| public OutputStream | getOutputStream()
Overrides java. |
| public int | getReceiveBufferSize()
Overrides java. 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. null if it is unconnected.
|
| public int | getSendBufferSize()
Overrides java. SO_SNDBUF option
for this Socket, that is the buffer size used by the platform
for output on this Socket.
|
| public int | |
| private void | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | isInputShutdown()
Overrides java. |
| public boolean | isOutputShutdown()
Overrides java. |
| public void | setKeepAlive(boolean
whether or not to have socket keep alive turned on. on)Overrides java. SO_KEEPALIVE.
|
| public void | setReceiveBufferSize(int
the size to which to set the receive buffer
size. This value must be greater than 0. size)Overrides java. SO_RCVBUF option to the
specified value for this Socket.
|
| public void | setSendBufferSize(int
the size to which to set the send buffer
size. This value must be greater than 0. size)Overrides java. SO_SNDBUF option to the
specified value for this Socket.
|
| public void | setSoTimeout(int
the specified timeout, in milliseconds. timeout)Overrides java. SO_TIMEOUT
with the specified timeout, in milliseconds.
|
| public void | shutdownInput()
Overrides java. |
| public void | shutdownOutput()
Overrides java. |
| chan | back to summary |
|---|---|
| private UnixSocketChannel chan | |
| closed | back to summary |
|---|---|
| private AtomicBoolean closed | |
| in | back to summary |
|---|---|
| private InputStream in Hides java. | |
| indown | back to summary |
|---|---|
| private AtomicBoolean indown | |
| out | back to summary |
|---|---|
| private OutputStream out Hides java. | |
| outdown | back to summary |
|---|---|
| private AtomicBoolean outdown | |
| UnixSocket | back to summary |
|---|---|
| public UnixSocket(UnixSocketChannel chan) | |
| bind | back to summary |
|---|---|
| public void bind(SocketAddress local) throws IOException Overrides java. Doc from java. Binds the socket to a local address.
If the address is
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this socket.
Any thread currently blocked in an I/O operation upon this socket
will throw a Once a socket has been closed, it is not available for further networking use (i.e. can't be reconnected or rebound). A new socket needs to be created. Closing this socket will also close the socket's
If this socket has an associated channel then the channel is closed as well.
| |
| connect | back to summary |
|---|---|
| public void connect(SocketAddress addr) throws IOException Overrides java. Doc from java. Connects this socket to the server. This method is interruptible in the following circumstances:
| |
| connect | back to summary |
|---|---|
| public void connect(SocketAddress addr, int timeout) throws IOException Overrides java. Doc from java. Connects this socket to the server with a specified timeout value. A timeout of zero is interpreted as an infinite timeout. The connection will then block until established or an error occurs. This method is interruptible in the following circumstances:
| |
| getChannel | back to summary |
|---|---|
| public SocketChannel getChannel() Overrides java. Doc from java. Returns the unique A socket will have a channel if, and only if, the channel itself was
created via the
| |
| getCredentials | back to summary |
|---|---|
| public final Credentials getCredentials() throws SocketException Retrieves the credentials for this UNIX socket. Clients calling this method will receive the server's credentials, and servers will receive the client's credentials. User ID, group ID, and PID are supplied. See man unix 7; SCM_CREDENTIALS
| |
| getInetAddress | back to summary |
|---|---|
| public InetAddress getInetAddress() Overrides java. Doc from java. Returns the address to which the socket is connected.
If the socket was connected prior to being
| |
| getInputStream | back to summary |
|---|---|
| public InputStream getInputStream() throws IOException Overrides java. Doc from java. Returns an input stream for this socket. If this socket has an associated channel then the resulting input
stream delegates all of its operations to the channel. If the channel
is in non-blocking mode then the input stream's Reading from the input stream is interruptible in the following circumstances:
Under abnormal conditions the underlying connection may be broken by the remote host or the network software (for example a connection reset in the case of TCP connections). When a broken connection is detected by the network software the following applies to the returned input stream :-
Closing the returned
| |
| getKeepAlive | back to summary |
|---|---|
| public boolean getKeepAlive() throws SocketException Overrides java. Doc from java. Tests if
| |
| getLocalSocketAddress | back to summary |
|---|---|
| public SocketAddress getLocalSocketAddress() Overrides java. Doc from java. Returns the address of the endpoint this socket is bound to.
If a socket bound to an endpoint represented by an
If there is a security manager set, its
| |
| getOutputStream | back to summary |
|---|---|
| public OutputStream getOutputStream() throws IOException Overrides java. Doc from java. Returns an output stream for this socket. If this socket has an associated channel then the resulting output
stream delegates all of its operations to the channel. If the channel
is in non-blocking mode then the output stream's Writing to the output stream is interruptible in the following circumstances:
Closing the returned
| |
| getReceiveBufferSize | back to summary |
|---|---|
| public int getReceiveBufferSize() throws SocketException Overrides java. Doc from java. Gets the value of the
| |
| getRemoteSocketAddress | back to summary |
|---|---|
| public SocketAddress getRemoteSocketAddress() Overrides java. Doc from java. Returns the address of the endpoint this socket is connected to, or
If the socket was connected prior to being
| |
| getSendBufferSize | back to summary |
|---|---|
| public int getSendBufferSize() throws SocketException Overrides java. Doc from java. Get value of the
| |
| getSoTimeout | back to summary |
|---|---|
| public int getSoTimeout() throws SocketException Overrides java. Doc from java. Returns setting for
| |
| ignore | back to summary |
|---|---|
| private void ignore() | |
| isBound | back to summary |
|---|---|
| public boolean isBound() Overrides java. Doc from java. Returns the binding state of the socket. Note Closing a socket doesn't clear its binding state, which means
this method will return
| |
| isClosed | back to summary |
|---|---|
| public boolean isClosed() Overrides java. Doc from java. Returns the closed state of the socket.
| |
| isConnected | back to summary |
|---|---|
| public boolean isConnected() Overrides java. Doc from java. Returns the connection state of the socket. Note Closing a socket doesn't clear its connection state, which means
this method will return
| |
| isInputShutdown | back to summary |
|---|---|
| public boolean isInputShutdown() Overrides java. Doc from java. Returns whether the read-half of the socket connection is closed.
| |
| isOutputShutdown | back to summary |
|---|---|
| public boolean isOutputShutdown() Overrides java. Doc from java. Returns whether the write-half of the socket connection is closed.
| |
| setKeepAlive | back to summary |
|---|---|
| public void setKeepAlive(boolean on) throws SocketException Overrides java. Doc from java. Enable/disable
| |
| setReceiveBufferSize | back to summary |
|---|---|
| public void setReceiveBufferSize(int size) throws SocketException Overrides java. Doc from java. Sets the Increasing the receive buffer size can increase the performance of network I/O for high-volume connection, while decreasing it can help reduce the backlog of incoming data. Because The value of
| |
| setSendBufferSize | back to summary |
|---|---|
| public void setSendBufferSize(int size) throws SocketException Overrides java. Doc from java. Sets the Because
| |
| setSoTimeout | back to summary |
|---|---|
| public void setSoTimeout(int timeout) throws SocketException Overrides java. Doc from java. Enable/disable
| |
| shutdownInput | back to summary |
|---|---|
| public void shutdownInput() throws IOException Overrides java. Doc from java. Places the input stream for this socket at "end of stream". Any data sent to the input stream side of the 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
| |
| shutdownOutput | back to summary |
|---|---|
| public void shutdownOutput() throws IOException Overrides java. Doc from java. 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.
| |
SelectableChannel. Though
that type isn't in the public API, if the channel passed in implements
that interface then unwanted synchronization is performed which can harm
concurrency and can cause deadlocks.
https://bugs.openjdk.java.net/browse/JDK-4774871
| Modifier and Type | Field and Description |
|---|---|
| private final UnixSocketChannel |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public boolean | |
| public int | read(ByteBuffer
The buffer into which bytes are to be transferred dst)Implements java. |
| public int | write(ByteBuffer
The buffer from which bytes are to be retrieved src)Implements java. |
| channel | back to summary |
|---|---|
| private final UnixSocketChannel channel | |
| UnselectableByteChannel | back to summary |
|---|---|
| pack-priv UnselectableByteChannel(UnixSocketChannel channel) | |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements java. Doc from java. Closes this channel. After a channel is closed, any further attempt to invoke I/O
operations upon it will cause a If this channel is already closed then invoking this method has no effect. This method may be invoked at any time. If some other thread has already invoked it, however, then another invocation will block until the first invocation is complete, after which it will return without effect.
| |
| isOpen | back to summary |
|---|---|
| public boolean isOpen() Implements java. Doc from java. Tells whether or not this channel is open.
| |
| read | back to summary |
|---|---|
| public int read(ByteBuffer dst) throws IOException Implements java. Doc from java. Reads a sequence of bytes from this channel into the given buffer. An attempt is made to read up to r bytes from the channel,
where r is the number of bytes remaining in the buffer, that is,
Suppose that a byte sequence of length n is read, where
A read operation might not fill the buffer, and in fact it might not read any bytes at all. Whether or not it does so depends upon the nature and state of the channel. A socket channel in non-blocking mode, for example, cannot read any more bytes than are immediately available from the socket's input buffer; similarly, a file channel cannot read any more bytes than remain in the file. It is guaranteed, however, that if a channel is in blocking mode and there is at least one byte remaining in the buffer then this method will block until at least one byte is read. This method may be invoked at any time. If another thread has already initiated a read operation upon this channel, however, then an invocation of this method will block until the first operation is complete.
| |
| write | back to summary |
|---|---|
| public int write(ByteBuffer src) throws IOException Implements java. Doc from java. Writes a sequence of bytes to this channel from the given buffer. An attempt is made to write up to r bytes to the channel,
where r is the number of bytes remaining in the buffer, that is,
Suppose that a byte sequence of length n is written, where
Unless otherwise specified, a write operation will return only after writing all of the r requested bytes. Some types of channels, depending upon their state, may write only some of the bytes or possibly none at all. A socket channel in non-blocking mode, for example, cannot write any more bytes than are free in the socket's output buffer. This method may be invoked at any time. If another thread has already initiated a write operation upon this channel, however, then an invocation of this method will block until the first operation is complete.
| |