Build 1.0_r1(from source)

android.net
Class LocalSocketImpl

java.lang.Object
  extended by android.net.LocalSocketImpl

 class LocalSocketImpl
extends Object

Socket implementation used for android.net.LocalSocket and android.net.LocalServerSocket. Supports only AF_LOCAL sockets.


Nested Class Summary
(package private)  class LocalSocketImpl.SocketInputStream
          An input stream for local sockets.
(package private)  class LocalSocketImpl.SocketOutputStream
          An output stream for local sockets.
 
Field Summary
(package private)  FileDescriptor[] inboundFileDescriptors
          file descriptor array received during a previous read
(package private)  FileDescriptor[] outboundFileDescriptors
          file descriptor array that should be written during next write
 
Constructor Summary
LocalSocketImpl()
          Create a new instance.
LocalSocketImpl(FileDescriptor fd)
          Create a new instance from a file descriptor representing a bound socket.
 
Method Summary
protected  void accept(LocalSocketImpl s)
          Accepts a new connection to the socket.
protected  int available()
          Returns the number of bytes available for reading without blocking.
 void bind(LocalSocketAddress endpoint)
          Binds this socket to an endpoint name.
 void close()
          Closes the socket.
protected  void connect(LocalSocketAddress address, int timeout)
          note timeout presently ignored
 void create(boolean stream)
          Creates a socket in the underlying OS.
protected  void finalize()
          Called by the virtual machine when there are no longer any (non-weak) references to the receiver.
 FileDescriptor[] getAncillaryFileDescriptors()
          Retrieves a set of file descriptors that a peer has sent through an ancillary message.
protected  FileDescriptor getFileDescriptor()
           
protected  InputStream getInputStream()
          Retrieves the input stream for this instance.
 Object getOption(int optID)
           
protected  OutputStream getOutputStream()
          Retrieves the output stream for this instance.
 Credentials getPeerCredentials()
          Retrieves the credentials of this socket's peer.
 LocalSocketAddress getSockAddress()
          Retrieves the socket name from the OS.
protected  void listen(int backlog)
           
protected  void sendUrgentData(int data)
           
 void setFileDescriptorsForSend(FileDescriptor[] fds)
          Enqueues a set of file descriptors to send to the peer.
 void setOption(int optID, Object value)
           
protected  void shutdownInput()
          Shuts down the input side of the socket.
protected  void shutdownOutput()
          Shuts down the output side of the socket.
protected  boolean supportsUrgentData()
           
 String toString()
          Returns a string containing a concise, human-readable description of the receiver.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

inboundFileDescriptors

FileDescriptor[] inboundFileDescriptors
file descriptor array received during a previous read


outboundFileDescriptors

FileDescriptor[] outboundFileDescriptors
file descriptor array that should be written during next write

Constructor Detail

LocalSocketImpl

LocalSocketImpl()
Create a new instance.


LocalSocketImpl

LocalSocketImpl(FileDescriptor fd)
          throws IOException
Create a new instance from a file descriptor representing a bound socket. The state of the file descriptor is not checked here but the caller can verify socket state by calling listen().

Parameters:
fd - non-null; bound file descriptor
Throws:
IOException
Method Detail

toString

public String toString()
Description copied from class: Object
Returns a string containing a concise, human-readable description of the receiver.

Overrides:
toString in class Object
Returns:
String a printable representation for the receiver.

create

public void create(boolean stream)
            throws IOException
Creates a socket in the underlying OS.

Parameters:
stream - true if this should be a stream socket, false for datagram.
Throws:
IOException

close

public void close()
           throws IOException
Closes the socket.

Throws:
IOException

connect

protected void connect(LocalSocketAddress address,
                       int timeout)
                throws IOException
note timeout presently ignored

Throws:
IOException

bind

public void bind(LocalSocketAddress endpoint)
          throws IOException
Binds this socket to an endpoint name. May only be called on an instance that has not yet been bound.

Parameters:
endpoint - endpoint address
Throws:
IOException

listen

protected void listen(int backlog)
               throws IOException
Throws:
IOException

accept

protected void accept(LocalSocketImpl s)
               throws IOException
Accepts a new connection to the socket. Blocks until a new connection arrives.

Parameters:
s - a socket that will be used to represent the new connection.
Throws:
IOException

getInputStream

protected InputStream getInputStream()
                              throws IOException
Retrieves the input stream for this instance.

Returns:
input stream
Throws:
IOException - if socket has been closed or cannot be created.

getOutputStream

protected OutputStream getOutputStream()
                                throws IOException
Retrieves the output stream for this instance.

Returns:
output stream
Throws:
IOException - if socket has been closed or cannot be created.

available

protected int available()
                 throws IOException
Returns the number of bytes available for reading without blocking.

Returns:
>= 0 count bytes available
Throws:
IOException

shutdownInput

protected void shutdownInput()
                      throws IOException
Shuts down the input side of the socket.

Throws:
IOException

shutdownOutput

protected void shutdownOutput()
                       throws IOException
Shuts down the output side of the socket.

Throws:
IOException

getFileDescriptor

protected FileDescriptor getFileDescriptor()

supportsUrgentData

protected boolean supportsUrgentData()

sendUrgentData

protected void sendUrgentData(int data)
                       throws IOException
Throws:
IOException

getOption

public Object getOption(int optID)
                 throws IOException
Throws:
IOException

setOption

public void setOption(int optID,
                      Object value)
               throws IOException
Throws:
IOException

setFileDescriptorsForSend

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.
Throws:
IOException

getAncillaryFileDescriptors

public FileDescriptor[] getAncillaryFileDescriptors()
                                             throws IOException
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
Throws:
IOException

getPeerCredentials

public Credentials getPeerCredentials()
                               throws IOException
Retrieves the credentials of this socket's peer. Only valid on connected sockets.

Returns:
non-null; peer credentials
Throws:
IOException

getSockAddress

public LocalSocketAddress getSockAddress()
                                  throws IOException
Retrieves the socket name from the OS.

Returns:
non-null; socket name
Throws:
IOException - on failure

finalize

protected void finalize()
                 throws IOException
Description copied from class: Object
Called by the virtual machine when there are no longer any (non-weak) references to the receiver. Subclasses can use this facility to guarantee that any associated resources are cleaned up before the receiver is garbage collected. Uncaught exceptions which are thrown during the running of the method cause it to terminate immediately, but are otherwise ignored.

Note: The virtual machine assumes that the implementation in class Object is empty.

Overrides:
finalize in class Object
Throws:
IOException

Build 1.0_r1(from source)

Please submit a feedback, bug or feature