java.net
Class Socket

java.lang.Object
  extended by java.net.Socket

public class Socket
extends Object

Socket. Allows a NXT to establish a connection with a remote Socket server via a proxy server. Version 1.1 uses NXTConnection and does not need to distinguish between USB and Bluetooth.

Version:
1.1
Author:
Ranulf Green & Lawrie Griffiths

Constructor Summary
Socket(NXTConnection nxtc)
          Constructor.
Socket(String host, int port, NXTConnection nxtc)
          Constructor: Pass an open NXT connection and socket details.
 
Method Summary
 void close()
          Write Escape sequence to indicate end of file
 DataInputStream getDataInputStream()
          Returns the data input stream of the socket
 DataOutputStream getDataOutputStream()
          Returns the data output stream of the socket
 InputStream getInputStream()
          Returns the input stream associated with this socket
 OutputStream getOutputStream()
          Returns the output stream associated with this socket
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Socket

public Socket(String host,
              int port,
              NXTConnection nxtc)
       throws IOException
Constructor: Pass an open NXT connection and socket details.

Parameters:
host - The name of the host with which the socket will be opened
port - The port to connect to
nxtc - The NXT connection
Throws:
IOException - If the host does not respond or the proxy is not running

Socket

public Socket(NXTConnection nxtc)
Constructor. Use if the socket is intended not to connect to a host

Parameters:
nxtc - the connection the socket is made over
Method Detail

getDataInputStream

public DataInputStream getDataInputStream()
                                   throws IOException
Returns the data input stream of the socket

Returns:
The data input stream of the socket
Throws:
IOException

getDataOutputStream

public DataOutputStream getDataOutputStream()
                                     throws IOException
Returns the data output stream of the socket

Returns:
The data output stream of the socket
Throws:
IOException

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Returns the output stream associated with this socket

Returns:
The output stream
Throws:
IOException

getInputStream

public InputStream getInputStream()
                           throws IOException
Returns the input stream associated with this socket

Returns:
The input stream
Throws:
IOException

close

public void close()
Write Escape sequence to indicate end of file