Methods Summary |
---|
public void | bind(LocalSocketAddress bindpoint)Binds this socket to an endpoint name. May only be called on an instance
that has not yet been bound.
implCreateIfNeeded();
synchronized (this) {
if (isBound) {
throw new IOException("already bound");
}
localAddress = bindpoint;
impl.bind(localAddress);
isBound = true;
}
|
public void | close()Closes the socket.
implCreateIfNeeded();
impl.close();
|
public void | connect(LocalSocketAddress endpoint, int timeout)
throw new UnsupportedOperationException();
|
public void | connect(LocalSocketAddress endpoint)Connects this socket to an endpoint. May only be called on an instance
that has not yet been connected.
synchronized (this) {
if (isConnected) {
throw new IOException("already connected");
}
implCreateIfNeeded();
impl.connect(endpoint, 0);
isConnected = true;
isBound = true;
}
|
public java.io.FileDescriptor[] | getAncillaryFileDescriptors()Retrieves a set of file descriptors that a peer has sent through
an ancillary message. This method retrieves the most recent set sent,
and then returns null until a new set arrives.
File descriptors may only be passed along with regular data, so this
method can only return a non-null after a read operation.
return impl.getAncillaryFileDescriptors();
|
public java.io.FileDescriptor | getFileDescriptor()Returns file descriptor or null if not yet open/already closed
return impl.getFileDescriptor();
|
public java.io.InputStream | getInputStream()Retrieves the input stream for this instance.
implCreateIfNeeded();
return impl.getInputStream();
|
public LocalSocketAddress | getLocalSocketAddress()Retrieves the name that this socket is bound to, if any.
return localAddress;
|
public java.io.OutputStream | getOutputStream()Retrieves the output stream for this instance.
implCreateIfNeeded();
return impl.getOutputStream();
|
public Credentials | getPeerCredentials()Retrieves the credentials of this socket's peer. Only valid on
connected sockets.
return impl.getPeerCredentials();
|
public int | getReceiveBufferSize()
return ((Integer) impl.getOption(SocketOptions.SO_RCVBUF)).intValue();
|
public LocalSocketAddress | getRemoteSocketAddress()
throw new UnsupportedOperationException();
|
public int | getSendBufferSize()
return ((Integer) impl.getOption(SocketOptions.SO_SNDBUF)).intValue();
|
public int | getSoTimeout()
return ((Integer) impl.getOption(SocketOptions.SO_TIMEOUT)).intValue();
|
private void | implCreateIfNeeded()It's difficult to discern from the spec when impl.create() should be
called, but it seems like a reasonable rule is "as soon as possible,
but not in a context where IOException cannot be thrown"
if (!implCreated) {
synchronized (this) {
if (!implCreated) {
try {
impl.create(sockType);
} finally {
implCreated = true;
}
}
}
}
|
public synchronized boolean | isBound()
return isBound;
|
public boolean | isClosed()
throw new UnsupportedOperationException();
|
public synchronized boolean | isConnected()
return isConnected;
|
public boolean | isInputShutdown()
throw new UnsupportedOperationException();
|
public boolean | isOutputShutdown()
throw new UnsupportedOperationException();
|
public void | setFileDescriptorsForSend(java.io.FileDescriptor[] fds)Enqueues a set of file descriptors to send to the peer. The queue
is one deep. The file descriptors will be sent with the next write
of normal data, and will be delivered in a single ancillary message.
See "man 7 unix" SCM_RIGHTS on a desktop Linux machine.
impl.setFileDescriptorsForSend(fds);
|
public void | setReceiveBufferSize(int size)
impl.setOption(SocketOptions.SO_RCVBUF, Integer.valueOf(size));
|
public void | setSendBufferSize(int n)
impl.setOption(SocketOptions.SO_SNDBUF, Integer.valueOf(n));
|
public void | setSoTimeout(int n)
impl.setOption(SocketOptions.SO_TIMEOUT, Integer.valueOf(n));
|
public void | shutdownInput()Shuts down the input side of the socket.
implCreateIfNeeded();
impl.shutdownInput();
|
public void | shutdownOutput()Shuts down the output side of the socket.
implCreateIfNeeded();
impl.shutdownOutput();
|
public java.lang.String | toString(){@inheritDoc}
return super.toString() + " impl:" + impl;
|