SunSPOT API V6.0


com.sun.spot.io.j2me.tcp
Class TCPConnection

java.lang.Object
  extended by com.sun.spot.io.j2me.tcp.TCPConnection
All Implemented Interfaces:
ITimeoutableConnection, Connection, InputConnection, OutputConnection, StreamConnection

public class TCPConnection
extends Object
implements StreamConnection, ITimeoutableConnection

This class provides the "tcp" protocol for accessing the SPOT radio using TCP streams. It is an implementor of StreamConnection

See Also:
StreamConnection

Constructor Summary
TCPConnection()
          DO NOT USE THIS CONSTRUCTOR - connections should be created using Connector.open(...)
TCPConnection(String addr, int portNo, boolean isServer, boolean timeouts)
          DO NOT USE THIS CONSTRUCTOR - connections should be created using Connector.open(...)
 
Method Summary
 void close()
          Close the connection.
 int getLocalPort()
           
 Inet6Address getRemoteAddress()
           
 int getRemotePort()
           
 long getTimeout()
          Get the timeout for receiving information on this connection
 Connection open(String arg0, String arg1, int arg2, boolean arg3)
           
 DataInputStream openDataInputStream()
          Open and return a data input stream for a connection.
 DataOutputStream openDataOutputStream()
          Open and return a data output stream for a connection.
 InputStream openInputStream()
          Open and return an input stream for a connection.
 OutputStream openOutputStream()
          Open and return an output stream for a connection.
 void setTimeout(long time)
          Set the timeout for receiving information on this connection
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TCPConnection

public TCPConnection(String addr,
                     int portNo,
                     boolean isServer,
                     boolean timeouts)
              throws IOException
DO NOT USE THIS CONSTRUCTOR - connections should be created using Connector.open(...) Creates a new TCPConnection object.

Parameters:
addr - The IPv6 address of the remote end of the connection. If this is not specified then this end of the connection is a server connection.
portNo - The IPv6 TCP port number of the remote end of the connection. If this is a server connection, this port number is the port number of this end of the server connection.
isServer - Defines whether this is a server side connection.
timeouts - The default timeout for socket operations.
Throws:
IOException

TCPConnection

public TCPConnection()
DO NOT USE THIS CONSTRUCTOR - connections should be created using Connector.open(...)

Method Detail

openInputStream

public InputStream openInputStream()
Description copied from interface: InputConnection
Open and return an input stream for a connection.

Specified by:
openInputStream in interface InputConnection
Returns:
An input stream

openOutputStream

public OutputStream openOutputStream()
Description copied from interface: OutputConnection
Open and return an output stream for a connection.

Specified by:
openOutputStream in interface OutputConnection
Returns:
An output stream

openDataInputStream

public DataInputStream openDataInputStream()
Description copied from interface: InputConnection
Open and return a data input stream for a connection.

Specified by:
openDataInputStream in interface InputConnection
Returns:
An input stream

openDataOutputStream

public DataOutputStream openDataOutputStream()
Description copied from interface: OutputConnection
Open and return a data output stream for a connection.

Specified by:
openDataOutputStream in interface OutputConnection
Returns:
An output stream

close

public void close()
           throws IOException
Description copied from interface: Connection
Close the connection.

When a connection has been closed, access to any of its methods that involve an I/O operation will cause an IOException to be thrown. Closing an already closed connection has no effect. Streams derived from the connection may be open when method is called. Any open streams will cause the connection to be held open until they themselves are closed. In this latter case access to the open streams is permitted, but access to the connection is not.

Specified by:
close in interface Connection
Throws:
IOException - If an I/O error occurs

open

public Connection open(String arg0,
                       String arg1,
                       int arg2,
                       boolean arg3)
                throws IOException
Throws:
IOException

getRemoteAddress

public Inet6Address getRemoteAddress()

getLocalPort

public int getLocalPort()

getRemotePort

public int getRemotePort()

getTimeout

public long getTimeout()
Description copied from interface: ITimeoutableConnection
Get the timeout for receiving information on this connection

Specified by:
getTimeout in interface ITimeoutableConnection
Returns:
- Timeout period in milliseconds. Answers -1 for infinite wait.

setTimeout

public void setTimeout(long time)
Description copied from interface: ITimeoutableConnection
Set the timeout for receiving information on this connection

Specified by:
setTimeout in interface ITimeoutableConnection
Parameters:
time - - Timeout period in milliseconds. Set this to -1 to turn off timeouts (infinite wait), or to 0 or more to wait that long for data before throwing a TimeoutException.

SunSPOT API V6.0


Copyright © 2006-2010 Oracle. All Rights Reserved.