gnu.net.local
Class AfUnixSocket

java.lang.Object
  |
  +--gnu.net.local.AfUnixSocket

public class AfUnixSocket
extends java.lang.Object

This class models a client side AF_UNIX socket. An AF_UNIX socket is a local endpoint for network communications conceptually similar to a file handle.

To use this library you have to include the native library 'libgnu_net_localX.so' in your LD_LIBRARY_PATH

If you want to check whether the AF_UNIX native library can be loaded/used at all before creating a socket try AfUnixSocketImpl.loadNativeLibrary() and catch UnsatisfiedLinkError.


Constructor Summary
AfUnixSocket()
          Initializes a new instance of AfUnixSocket object without connecting.
AfUnixSocket(java.lang.String sockname)
          Initializes a new instance of AfUnixSocket and connects to the socket specified as arguments.
 
Method Summary
 void close()
          Closes the Socket
 java.io.InputStream getInputStream()
          Returns an InputStream for reading from this socket.
 java.io.OutputStream getOutputStream()
          Returns an OutputStream for writing to this socket.
 java.lang.String toString()
          Converts this AfUnixSocket to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AfUnixSocket

public AfUnixSocket()
Initializes a new instance of AfUnixSocket object without connecting. This useful for subclasses of socket that might want this behavior.

Throws:
java.lang.UnsatisfiedLinkError - loads the native library- throws UnsatisfiedLinkError on failure

AfUnixSocket

public AfUnixSocket(java.lang.String sockname)
             throws java.io.IOException
Initializes a new instance of AfUnixSocket and connects to the socket specified as arguments.

Parameters:
sockname - The name of the socket to connect to
Throws:
java.io.IOException - If an error occurs
java.lang.UnsatisfiedLinkError - loads the native libraray - throws UnsatisfiedLinkError on failure
Method Detail

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns an InputStream for reading from this socket.

Returns:
The InputStream object
Throws:
java.io.IOException - If an error occurs or Socket is not connected

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Returns an OutputStream for writing to this socket.

Returns:
The OutputStream object
Throws:
java.io.IOException - If an error occurs or Socket is not connected

close

public void close()
           throws java.io.IOException
Closes the Socket

Throws:
java.io.IOException - If an error occurs

toString

public java.lang.String toString()
Converts this AfUnixSocket to a String.

Overrides:
toString in class java.lang.Object
Returns:
The String representation of this Socket