Methods Summary |
---|
private native java.io.FileDescriptor | accept(java.io.FileDescriptor fd, android.net.LocalSocketImpl s)Accepts a connection on a server socket.
|
protected void | accept(android.net.LocalSocketImpl s)Accepts a new connection to the socket. Blocks until a new
connection arrives.
if (fd == null) {
throw new IOException("socket not created");
}
s.fd = accept(fd, s);
s.mFdCreatedInternally = true;
|
protected int | available()Returns the number of bytes available for reading without blocking.
return getInputStream().available();
|
private native int | available_native(java.io.FileDescriptor fd)
|
public void | bind(LocalSocketAddress endpoint)Binds this socket to an endpoint name. May only be called on an instance
that has not yet been bound.
if (fd == null) {
throw new IOException("socket not created");
}
bindLocal(fd, endpoint.getName(), endpoint.getNamespace().getId());
|
private native void | bindLocal(java.io.FileDescriptor fd, java.lang.String name, int namespace)
|
public void | close()Closes the socket.
synchronized (LocalSocketImpl.this) {
if ((fd == null) || (mFdCreatedInternally == false)) {
fd = null;
return;
}
try {
Os.close(fd);
} catch (ErrnoException e) {
e.rethrowAsIOException();
}
fd = null;
}
|
protected void | connect(LocalSocketAddress address, int timeout)note timeout presently ignored
if (fd == null) {
throw new IOException("socket not created");
}
connectLocal(fd, address.getName(), address.getNamespace().getId());
|
private native void | connectLocal(java.io.FileDescriptor fd, java.lang.String name, int namespace)
|
public void | create(int sockType)Creates a socket in the underlying OS.
// no error if socket already created
// need this for LocalServerSocket.accept()
if (fd == null) {
int osType;
switch (sockType) {
case LocalSocket.SOCKET_DGRAM:
osType = OsConstants.SOCK_DGRAM;
break;
case LocalSocket.SOCKET_STREAM:
osType = OsConstants.SOCK_STREAM;
break;
case LocalSocket.SOCKET_SEQPACKET:
osType = OsConstants.SOCK_SEQPACKET;
break;
default:
throw new IllegalStateException("unknown sockType");
}
try {
fd = Os.socket(OsConstants.AF_UNIX, osType, 0);
mFdCreatedInternally = true;
} catch (ErrnoException e) {
e.rethrowAsIOException();
}
}
|
protected void | finalize()
close();
|
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.
synchronized(readMonitor) {
FileDescriptor[] result = inboundFileDescriptors;
inboundFileDescriptors = null;
return result;
}
|
protected java.io.FileDescriptor | getFileDescriptor()
return fd;
|
protected java.io.InputStream | getInputStream()Retrieves the input stream for this instance.
if (fd == null) {
throw new IOException("socket not created");
}
synchronized (this) {
if (fis == null) {
fis = new SocketInputStream();
}
return fis;
}
|
public java.lang.Object | getOption(int optID)
if (fd == null) {
throw new IOException("socket not created");
}
if (optID == SocketOptions.SO_TIMEOUT) {
return 0;
}
int value = getOption_native(fd, optID);
switch (optID)
{
case SocketOptions.SO_RCVBUF:
case SocketOptions.SO_SNDBUF:
return value;
case SocketOptions.SO_REUSEADDR:
default:
return value;
}
|
private native int | getOption_native(java.io.FileDescriptor fd, int optID)
|
protected java.io.OutputStream | getOutputStream()Retrieves the output stream for this instance.
if (fd == null) {
throw new IOException("socket not created");
}
synchronized (this) {
if (fos == null) {
fos = new SocketOutputStream();
}
return fos;
}
|
public Credentials | getPeerCredentials()Retrieves the credentials of this socket's peer. Only valid on
connected sockets.
return getPeerCredentials_native(fd);
|
private native Credentials | getPeerCredentials_native(java.io.FileDescriptor fd)
|
public LocalSocketAddress | getSockAddress()Retrieves the socket name from the OS.
return null;
//TODO implement this
//return getSockName_native(fd);
|
protected void | listen(int backlog)
if (fd == null) {
throw new IOException("socket not created");
}
listen_native(fd, backlog);
|
private native void | listen_native(java.io.FileDescriptor fd, int backlog)
|
private native int | pending_native(java.io.FileDescriptor fd)
|
private native int | read_native(java.io.FileDescriptor fd)
|
private native int | readba_native(byte[] b, int off, int len, java.io.FileDescriptor fd)
|
protected void | sendUrgentData(int data)
throw new RuntimeException ("not impled");
|
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.
synchronized(writeMonitor) {
outboundFileDescriptors = fds;
}
|
public void | setOption(int optID, java.lang.Object value)
/*
* Boolean.FALSE is used to disable some options, so it
* is important to distinguish between FALSE and unset.
* We define it here that -1 is unset, 0 is FALSE, and 1
* is TRUE.
*/
int boolValue = -1;
int intValue = 0;
if (fd == null) {
throw new IOException("socket not created");
}
if (value instanceof Integer) {
intValue = (Integer)value;
} else if (value instanceof Boolean) {
boolValue = ((Boolean) value)? 1 : 0;
} else {
throw new IOException("bad value: " + value);
}
setOption_native(fd, optID, boolValue, intValue);
|
private native void | setOption_native(java.io.FileDescriptor fd, int optID, int b, int value)
|
private native void | shutdown(java.io.FileDescriptor fd, boolean shutdownInput)
|
protected void | shutdownInput()Shuts down the input side of the socket.
if (fd == null) {
throw new IOException("socket not created");
}
shutdown(fd, true);
|
protected void | shutdownOutput()Shuts down the output side of the socket.
if (fd == null) {
throw new IOException("socket not created");
}
shutdown(fd, false);
|
protected boolean | supportsUrgentData()
return false;
|
public java.lang.String | toString()
return super.toString() + " fd:" + fd;
|
private native void | write_native(int b, java.io.FileDescriptor fd)
|
private native void | writeba_native(byte[] b, int off, int len, java.io.FileDescriptor fd)
|