android.net.LocalSocket
Creates a (non-server) socket in the UNIX-domain namespace. The interface
here is not entirely unlike that of java.net.Socket
Summary
Public Constructors
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Public Constructors
public
LocalSocket()
Creates a AF_LOCAL/UNIX domain stream socket.
Public Methods
Binds this socket to an endpoint name. May only be called on an instance
that has not yet been bound.
Parameters
bindpoint
| endpoint address |
Connects this socket to an endpoint. May only be called on an instance
that has not yet been connected.
Parameters
endpoint
| endpoint address |
Throws
IOException
| if socket is in invalid state or the address does
not exist.
|
public
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.
Returns
- null or file descriptor array
Returns file descriptor or null if not yet open/already closed
public
InputStream
getInputStream()
Retrieves the input stream for this instance.
Throws
IOException
| if socket has been closed or cannot be created.
|
Retrieves the name that this socket is bound to, if any.
Returns
- Local address or null if anonymous
public
OutputStream
getOutputStream()
Retrieves the output stream for this instance.
Throws
IOException
| if socket has been closed or cannot be created.
|
public
Credentials
getPeerCredentials()
Retrieves the credentials of this socket's peer. Only valid on
connected sockets.
Returns
- non-null; peer credentials
public
int
getReceiveBufferSize()
public
int
getSendBufferSize()
public
int
getSoTimeout()
public
synchronized
boolean
isBound()
public
boolean
isClosed()
public
synchronized
boolean
isConnected()
public
boolean
isInputShutdown()
public
boolean
isOutputShutdown()
public
void
setFileDescriptorsForSend(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.
Parameters
fds
| non-null; file descriptors to send.
|
public
void
setReceiveBufferSize(int size)
public
void
setSendBufferSize(int n)
public
void
setSoTimeout(int n)
public
void
shutdownInput()
Shuts down the input side of the socket.
public
void
shutdownOutput()
Shuts down the output side of the socket.
public
String
toString()
Returns a string containing a concise, human-readable description of the
receiver.
Returns
- String a printable representation for the receiver.