org.lirc.socket
Class UnixSocketImpl

java.lang.Object
  |
  +--org.lirc.socket.UnixSocketImpl

public class UnixSocketImpl
extends java.lang.Object

Implementation for both server and client sockets.

Version:
$Revision: 1.1 $
Author:
Bjorn Bringert (bjorn@mumblebee.com)

Constructor Summary
protected UnixSocketImpl()
          Creates a new UnixSocketImpl
 
Method Summary
protected  UnixSocketImpl accept()
          Listens for a connection to be made to this socket and accepts it.
protected  void bind(java.lang.String myPath)
          Binds to a path
protected  void close()
          Closes this socket
protected  void connect(java.lang.String path)
          Connects this socket to a path.
protected static int createSocket()
          Creates a native socket and returns its file descriptor.
protected  int getFd()
          Gets the file descriptor for the socket.
protected  org.lirc.socket.UnixSocketInputStream getInputStream()
          Returns an input stream for this socket.
protected  org.lirc.socket.UnixSocketOutputStream getOutputStream()
          Returns an output stream for this socket.
protected  void listen(int backlog)
          Starts listening.
protected  void shutdownInput()
          Disables the input stream for this socket.
protected  void shutdownOutput()
          Disables the output stream for this socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnixSocketImpl

protected UnixSocketImpl()
                  throws java.io.IOException
Creates a new UnixSocketImpl
Method Detail

getFd

protected int getFd()
Gets the file descriptor for the socket.
Returns:
a file descriptor, or -1 if there is none

createSocket

protected static int createSocket()
                           throws java.io.IOException
Creates a native socket and returns its file descriptor.
Throws:
java.io.IOException - if an I/O error occurs when creating the socket.

bind

protected void bind(java.lang.String myPath)
             throws java.io.IOException
Binds to a path
Parameters:
myPath - path to bind to.
Throws:
java.io.IOException - if an I/O error occurs when binding.

listen

protected void listen(int backlog)
               throws java.io.IOException
Starts listening.
Parameters:
backlog - The maximum length of the queue
Throws:
java.io.IOException - if an I/O error occurs.

accept

protected UnixSocketImpl accept()
                         throws java.io.IOException
Listens for a connection to be made to this socket and accepts it. The method blocks until a connection is made.
Returns:
the new UnixSocketImpl
Throws:
java.io.IOException - if an I/O error occurs when waiting for a connection.

connect

protected void connect(java.lang.String path)
                throws java.io.IOException
Connects this socket to a path.
Throws:
If - there is a problem connecting the socket

close

protected void close()
              throws java.io.IOException
Closes this socket
Throws:
java.io.IOException - If there is a problem closing the socket

shutdownInput

protected void shutdownInput()
                      throws java.io.IOException
Disables the input stream for this socket.
Throws:
java.io.IOException - if an I/O error occurs when shutting down this socket.

shutdownOutput

protected void shutdownOutput()
                       throws java.io.IOException
Disables the output stream for this socket.
Throws:
java.io.IOException - if an I/O error occurs when shutting down this socket.

getInputStream

protected org.lirc.socket.UnixSocketInputStream getInputStream()
                                                        throws java.io.IOException
Returns an input stream for this socket. This method should only be called once for a socket.
Returns:
an input stream for reading bytes from this socket.
Throws:
java.io.IOException - if an I/O error occurs when creating the input stream.

getOutputStream

protected org.lirc.socket.UnixSocketOutputStream getOutputStream()
                                                          throws java.io.IOException
Returns an output stream for this socket. This method should only be called once for a socket.
Returns:
an output stream for writing bytes to this socket.
Throws:
java.io.IOException - if an I/O error occurs when creating the output stream.