public class LocalSocket extends Object implements Closeable
Constructor and Description |
---|
LocalSocket()
Creates a AF_LOCAL/UNIX domain stream socket.
|
LocalSocket(FileDescriptor fd)
Creates a AF_LOCAL/UNIX domain stream socket with FileDescriptor.
|
Modifier and Type | Method and Description |
---|---|
void |
bind(LocalSocketAddress bindpoint)
Binds this socket to an endpoint name.
|
void |
close()
Closes the socket.
|
void |
connect(LocalSocketAddress endpoint)
Connects this socket to an endpoint.
|
void |
connect(LocalSocketAddress endpoint,
int timeout) |
FileDescriptor[] |
getAncillaryFileDescriptors()
Retrieves a set of file descriptors that a peer has sent through
an ancillary message.
|
FileDescriptor |
getFileDescriptor()
Returns file descriptor or null if not yet open/already closed
|
InputStream |
getInputStream()
Retrieves the input stream for this instance.
|
LocalSocketAddress |
getLocalSocketAddress()
Retrieves the name that this socket is bound to, if any.
|
OutputStream |
getOutputStream()
Retrieves the output stream for this instance.
|
Credentials |
getPeerCredentials()
Retrieves the credentials of this socket's peer.
|
int |
getReceiveBufferSize() |
LocalSocketAddress |
getRemoteSocketAddress() |
int |
getSendBufferSize() |
int |
getSoTimeout() |
boolean |
isBound() |
boolean |
isClosed() |
boolean |
isConnected() |
boolean |
isInputShutdown() |
boolean |
isOutputShutdown() |
void |
setFileDescriptorsForSend(FileDescriptor[] fds)
Enqueues a set of file descriptors to send to the peer.
|
void |
setReceiveBufferSize(int size) |
void |
setSendBufferSize(int n) |
void |
setSoTimeout(int n) |
void |
shutdownInput()
Shuts down the input side of the socket.
|
void |
shutdownOutput()
Shuts down the output side of the socket.
|
String |
toString()
Returns a string containing a concise, human-readable description of this
object.
|
public LocalSocket()
public LocalSocket(FileDescriptor fd) throws IOException
IOException
public String toString()
getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString
method
if you intend implementing your own toString
method.
public void connect(LocalSocketAddress endpoint) throws IOException
endpoint
- endpoint addressIOException
- if socket is in invalid state or the address does
not exist.public void bind(LocalSocketAddress bindpoint) throws IOException
bindpoint
- endpoint addressIOException
public LocalSocketAddress getLocalSocketAddress()
public InputStream getInputStream() throws IOException
IOException
- if socket has been closed or cannot be created.public OutputStream getOutputStream() throws IOException
IOException
- if socket has been closed or cannot be created.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void shutdownInput() throws IOException
IOException
public void shutdownOutput() throws IOException
IOException
public void setReceiveBufferSize(int size) throws IOException
IOException
public int getReceiveBufferSize() throws IOException
IOException
public void setSoTimeout(int n) throws IOException
IOException
public int getSoTimeout() throws IOException
IOException
public void setSendBufferSize(int n) throws IOException
IOException
public int getSendBufferSize() throws IOException
IOException
public LocalSocketAddress getRemoteSocketAddress()
public boolean isConnected()
public boolean isClosed()
public boolean isBound()
public boolean isOutputShutdown()
public boolean isInputShutdown()
public void connect(LocalSocketAddress endpoint, int timeout) throws IOException
IOException
public void setFileDescriptorsForSend(FileDescriptor[] fds)
fds
- non-null; file descriptors to send.public FileDescriptor[] getAncillaryFileDescriptors() throws IOException
IOException
public Credentials getPeerCredentials() throws IOException
IOException
public FileDescriptor getFileDescriptor()