|
SunSPOT API V6.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.squawk.io.ConnectionBase
com.sun.squawk.io.j2me.socket.Protocol
public class Protocol
Support for socket connections on device. This allows a generic stream connection with an external host (on a TCP network). This must be used in conjunction with a SocketProxy on a host computer.
| Field Summary | |
|---|---|
protected int |
port
|
| Fields inherited from interface javax.microedition.io.SocketConnection |
|---|
DELAY, KEEPALIVE, LINGER, RCVBUF, SNDBUF |
| Constructor Summary | |
|---|---|
Protocol()
|
|
Protocol(SocketConnection connection)
|
|
| Method Summary | |
|---|---|
void |
close()
Close the connection. |
String |
getAddress()
Gets the remote address to which the socket is bound. |
String |
getLocalAddress()
Gets the local address to which the socket is bound. |
int |
getLocalPort()
Returns the local port to which this socket is bound. |
int |
getPort()
Returns the remote port to which this socket is bound. |
int |
getSocketOption(byte option)
Get a socket option for the connection. |
Connection |
open(String protocol,
String originalName,
int mode,
boolean timeouts)
Open the connection |
InputStream |
openInputStream()
Returns an input stream for this socket. |
OutputStream |
openOutputStream()
Returns an output stream for this socket. |
void |
setSocketOption(byte option,
int value)
Set a socket option for the connection. |
| Methods inherited from class com.sun.squawk.io.ConnectionBase |
|---|
openDataInputStream, openDataOutputStream |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.microedition.io.InputConnection |
|---|
openDataInputStream |
| Methods inherited from interface javax.microedition.io.OutputConnection |
|---|
openDataOutputStream |
| Field Detail |
|---|
protected int port
| Constructor Detail |
|---|
public Protocol()
public Protocol(SocketConnection connection)
| Method Detail |
|---|
public Connection open(String protocol,
String originalName,
int mode,
boolean timeouts)
throws IOException
open in class ConnectionBaseoriginalName - protocol - The URL protocolmode - The access modetimeouts - A flag to indicate that the caller
wants timeout exceptions
IOException
ConnectionNotFoundException - If the connection cannot
be found.
public InputStream openInputStream()
throws IOException
openInputStream in interface InputConnectionopenInputStream in class ConnectionBaseIOException - if an I/O error occurs when creating the input stream.
public OutputStream openOutputStream()
throws IOException
openOutputStream in interface OutputConnectionopenOutputStream in class ConnectionBaseIOException - if an I/O error occurs when creating the
output stream.
public void close()
throws IOException
close in interface Connectionclose in class ConnectionBaseIOException - if an I/O error occurs when closing the
connection.
public String getAddress()
throws IOException
SocketConnection
getAddress in interface SocketConnectionIOException - if the connection was closed.
public String getLocalAddress()
throws IOException
SocketConnectionThe host address(IP number) that can be used to connect to this end of the socket connection from an external system. Since IP addresses may be dynamically assigned, a remote application will need to be robust in the face of IP number reasssignment.
The local hostname (if available) can be accessed from
System.getProperty("microedition.hostname")
getLocalAddress in interface SocketConnectionIOException - if the connection was closed.ServerSocketConnection
public int getLocalPort()
throws IOException
SocketConnection
getLocalPort in interface SocketConnectionIOException - if the connection was closed.ServerSocketConnection
public int getPort()
throws IOException
SocketConnection
getPort in interface SocketConnectionIOException - if the connection was closed.
public int getSocketOption(byte option)
throws IOException
SocketConnection
getSocketOption in interface SocketConnectionoption - socket option identifier (KEEPALIVE, LINGER, SNDBUF, RCVBUF,
or DELAY)
IOException - if the connection was closedSocketConnection.setSocketOption(byte, int)
public void setSocketOption(byte option,
int value)
throws IOException
SocketConnectionOptions inform the low level networking code about intended usage patterns that the application will use in dealing with the socket connection.
Calling setSocketOption to assign buffer sizes is a hint
to the platform of the sizes to set the underlying network I/O buffers.
Calling getSocketOption can be used to see what sizes the
system is using. The system MAY adjust the buffer sizes to account for
better throughput available from Maximum Transmission Unit (MTU) and
Maximum Segment Size (MSS) data available from current network
information.
setSocketOption in interface SocketConnectionoption - socket option identifier (KEEPALIVE, LINGER, SNDBUF, RCVBUF,
or DELAY)value - numeric value for specified option
IOException - if the connection was closedSocketConnection.getSocketOption(byte)
|
SunSPOT API V6.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||