LocalSocket
open class LocalSocket : Closeable
kotlin.Any | |
↳ | 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.
Summary
Constants | |
---|---|
static Int |
Datagram socket type |
static Int |
Sequential packet socket type |
static Int |
Stream socket type |
Public constructors | |
---|---|
Creates a AF_LOCAL/UNIX domain stream socket. |
|
LocalSocket(sockType: Int) Creates a AF_LOCAL/UNIX domain stream socket with given socket type |
Public methods | |
---|---|
open Unit |
bind(bindpoint: LocalSocketAddress!) Binds this socket to an endpoint name. |
open Unit |
close() Closes the socket. |
open Unit |
connect(endpoint: LocalSocketAddress!) Connects this socket to an endpoint. |
open Unit |
connect(endpoint: LocalSocketAddress!, timeout: Int) |
open Array<FileDescriptor!>! |
Retrieves a set of file descriptors that a peer has sent through an ancillary message. |
open FileDescriptor! |
Returns file descriptor or null if not yet open/already closed |
open InputStream! |
Retrieves the input stream for this instance. |
open LocalSocketAddress! |
Retrieves the name that this socket is bound to, if any. |
open OutputStream! |
Retrieves the output stream for this instance. |
open Credentials! |
Retrieves the credentials of this socket's peer. |
open Int | |
open LocalSocketAddress! | |
open Int | |
open Int | |
open Boolean |
isBound() |
open Boolean |
isClosed() |
open Boolean | |
open Boolean | |
open Boolean | |
open Unit |
setFileDescriptorsForSend(fds: Array<FileDescriptor!>!) Enqueues a set of file descriptors to send to the peer. |
open Unit |
setReceiveBufferSize(size: Int) |
open Unit |
setSendBufferSize(n: Int) |
open Unit |
setSoTimeout(n: Int) |
open Unit |
Shuts down the input side of the socket. |
open Unit |
Shuts down the output side of the socket. |
open String |
toString() Returns a string representation of the object. |
Constants
SOCKET_SEQPACKET
static val SOCKET_SEQPACKET: Int
Sequential packet socket type
Value: 3
Public constructors
LocalSocket
LocalSocket(sockType: Int)
Creates a AF_LOCAL/UNIX domain stream socket with given socket type
Parameters | |
---|---|
sockType |
Int: either SOCKET_DGRAM , SOCKET_STREAM or SOCKET_SEQPACKET |
Public methods
bind
open fun bind(bindpoint: LocalSocketAddress!): Unit
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 |
Exceptions | |
---|---|
java.io.IOException |
close
open fun close(): Unit
Closes the socket.
Exceptions | |
---|---|
java.lang.Exception |
if this resource cannot be closed |
java.io.IOException |
connect
open fun connect(endpoint: LocalSocketAddress!): Unit
Connects this socket to an endpoint. May only be called on an instance that has not yet been connected.
Parameters | |
---|---|
endpoint |
LocalSocketAddress!: endpoint address |
Exceptions | |
---|---|
java.io.IOException |
if socket is in invalid state or the address does not exist. |
getAncillaryFileDescriptors
open fun getAncillaryFileDescriptors(): Array<FileDescriptor!>!
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 | |
---|---|
Array<FileDescriptor!>! |
null or file descriptor array |
Exceptions | |
---|---|
java.io.IOException |
getFileDescriptor
open fun getFileDescriptor(): FileDescriptor!
Returns file descriptor or null if not yet open/already closed
Return | |
---|---|
FileDescriptor! |
fd or null |
getInputStream
open fun getInputStream(): InputStream!
Retrieves the input stream for this instance. Closing this stream is equivalent to closing the entire socket and its associated streams using #close().
Return | |
---|---|
InputStream! |
input stream |
Exceptions | |
---|---|
java.io.IOException |
if socket has been closed or cannot be created. |
getLocalSocketAddress
open fun getLocalSocketAddress(): LocalSocketAddress!
Retrieves the name that this socket is bound to, if any.
Return | |
---|---|
LocalSocketAddress! |
Local address or null if anonymous |
getOutputStream
open fun getOutputStream(): OutputStream!
Retrieves the output stream for this instance. Closing this stream is equivalent to closing the entire socket and its associated streams using #close().
Return | |
---|---|
OutputStream! |
output stream |
Exceptions | |
---|---|
java.io.IOException |
if socket has been closed or cannot be created. |
getPeerCredentials
open fun getPeerCredentials(): Credentials!
Retrieves the credentials of this socket's peer. Only valid on connected sockets.
Return | |
---|---|
Credentials! |
non-null; peer credentials |
Exceptions | |
---|---|
java.io.IOException |
setFileDescriptorsForSend
open fun setFileDescriptorsForSend(fds: Array<FileDescriptor!>!): Unit
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 |
Array<FileDescriptor!>!: non-null; file descriptors to send. |
shutdownInput
open fun shutdownInput(): Unit
Shuts down the input side of the socket.
Exceptions | |
---|---|
java.io.IOException |
shutdownOutput
open fun shutdownOutput(): Unit
Shuts down the output side of the socket.
Exceptions | |
---|---|
java.io.IOException |
toString
open fun toString(): String
Returns a string representation of the object.
Return | |
---|---|
String |
a string representation of the object. |