# Print output for @column tags ?>
public
class
LocalSocket
extends Object
implements
Closeable
java.lang.Object | |
↳ | 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. This class and the streams returned from it may be used from multiple threads.
Constants | |
---|---|
int |
SOCKET_DGRAM
Datagram socket type |
int |
SOCKET_SEQPACKET
Sequential packet socket type |
int |
SOCKET_STREAM
Stream socket type |
Public constructors | |
---|---|
LocalSocket()
Creates a AF_LOCAL/UNIX domain stream socket. |
|
LocalSocket(int sockType)
Creates a AF_LOCAL/UNIX domain stream socket with given socket type |
Public methods | |
---|---|
void
|
bind(LocalSocketAddress bindpoint)
Binds this socket to an endpoint name. |
void
|
close()
Closes the socket. |
void
|
connect(LocalSocketAddress endpoint, int timeout)
|
void
|
connect(LocalSocketAddress endpoint)
Connects this socket to an endpoint. |
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 representation of the object. |
Inherited methods | |
---|---|
public static final int SOCKET_DGRAM
Datagram socket type
Constant Value: 1 (0x00000001)
public static final int SOCKET_SEQPACKET
Sequential packet socket type
Constant Value: 3 (0x00000003)
public static final int SOCKET_STREAM
Stream socket type
Constant Value: 2 (0x00000002)
public LocalSocket ()
Creates a AF_LOCAL/UNIX domain stream socket.
public LocalSocket (int sockType)
Creates a AF_LOCAL/UNIX domain stream socket with given socket type
Parameters | |
---|---|
sockType |
int : either SOCKET_DGRAM , SOCKET_STREAM
or SOCKET_SEQPACKET |
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.
Parameters | |
---|---|
bindpoint |
LocalSocketAddress : endpoint address |
Throws | |
---|---|
|
java.io.IOException |
IOException |
public void connect (LocalSocketAddress endpoint, int timeout)
Parameters | |
---|---|
endpoint |
LocalSocketAddress |
timeout |
int |
Throws | |
---|---|
IOException |
public void connect (LocalSocketAddress endpoint)
Connects this socket to an endpoint. May only be called on an instance that has not yet been connected.
Parameters | |
---|---|
endpoint |
LocalSocketAddress : 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 | |
---|---|
FileDescriptor[] |
null or file descriptor array |
Throws | |
---|---|
|
java.io.IOException |
IOException |
public FileDescriptor getFileDescriptor ()
Returns file descriptor or null if not yet open/already closed
Returns | |
---|---|
FileDescriptor |
fd or null |
public InputStream getInputStream ()
Retrieves the input stream for this instance.
Returns | |
---|---|
InputStream |
input stream |
Throws | |
---|---|
IOException |
if socket has been closed or cannot be created. |
public LocalSocketAddress getLocalSocketAddress ()
Retrieves the name that this socket is bound to, if any.
Returns | |
---|---|
LocalSocketAddress |
Local address or null if anonymous |
public OutputStream getOutputStream ()
Retrieves the output stream for this instance.
Returns | |
---|---|
OutputStream |
output stream |
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 | |
---|---|
Credentials |
non-null; peer credentials |
Throws | |
---|---|
|
java.io.IOException |
IOException |
public LocalSocketAddress getRemoteSocketAddress ()
Returns | |
---|---|
LocalSocketAddress |
public boolean isBound ()
Returns | |
---|---|
boolean |
public boolean isClosed ()
Returns | |
---|---|
boolean |
public boolean isConnected ()
Returns | |
---|---|
boolean |
public boolean isInputShutdown ()
Returns | |
---|---|
boolean |
public boolean isOutputShutdown ()
Returns | |
---|---|
boolean |
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 |
FileDescriptor : non-null; file descriptors to send. |
public void setReceiveBufferSize (int size)
Parameters | |
---|---|
size |
int |
Throws | |
---|---|
IOException |
public void shutdownInput ()
Shuts down the input side of the socket.
Throws | |
---|---|
|
java.io.IOException |
IOException |
public void shutdownOutput ()
Shuts down the output side of the socket.
Throws | |
---|---|
|
java.io.IOException |
IOException |
public String toString ()
Returns a string representation of the object. In general, the
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Returns | |
---|---|
String |
a string representation of the object. |