|
" 2013 FRC Java API " |
|||||||||
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
Connection to the J2ME socket API.
Field Summary | |
---|---|
protected boolean |
isopen
Input stream open flag |
protected boolean |
osopen
Output stream open flag |
Fields inherited from interface javax.microedition.io.SocketConnection |
---|
DELAY, KEEPALIVE, LINGER, RCVBUF, SNDBUF |
Constructor Summary | |
---|---|
Protocol()
default constructor used by GCF |
|
Protocol(int fd)
Open the 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 name,
int mode,
boolean timeouts)
Open the connection |
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()
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 java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean isopen
protected boolean osopen
Constructor Detail |
---|
public Protocol()
public Protocol(int fd)
fd
- the accepted socket handleMethod Detail |
---|
public Connection open(String protocol, String name, int mode, boolean timeouts) throws IOException
open
in class ConnectionBase
name
- the target for the connection. It must be in this
format: "//mode
- read/write mode of the connection (currently ignored).timeouts
- A flag to indicate that the called wants timeout
exceptions (currently ignored).protocol
- The URL protocol
IOException
ConnectionNotFoundException
- If the connection cannot
be found.public InputStream openInputStream() throws IOException
openInputStream
in interface InputConnection
openInputStream
in class ConnectionBase
IOException
- if an I/O error occurs when creating the
input stream.public OutputStream openOutputStream() throws IOException
openOutputStream
in interface OutputConnection
openOutputStream
in class ConnectionBase
IOException
- if an I/O error occurs when creating the
output stream.public void close() throws IOException
close
in interface Connection
close
in class ConnectionBase
IOException
- if an I/O error occurs when closing the
connection.public DataInputStream openDataInputStream() throws IOException
openDataInputStream
in interface InputConnection
openDataInputStream
in class ConnectionBase
IOException
- If an I/O error occurspublic DataOutputStream openDataOutputStream() throws IOException
openDataOutputStream
in interface OutputConnection
openDataOutputStream
in class ConnectionBase
IOException
- If an I/O error occurspublic void setSocketOption(byte option, int value) throws IllegalArgumentException, IOException
SocketConnection
Options 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 SocketConnection
option
- socket option identifier (KEEPALIVE, LINGER, SNDBUF, RCVBUF,
or DELAY)value
- numeric value for specified option
IllegalArgumentException
- if the value is not valid (e.g., negative value) or if the
option identifier is not valid
IOException
- if the connection was closedSocketConnection.getSocketOption(byte)
public int getSocketOption(byte option) throws IllegalArgumentException, IOException
SocketConnection
getSocketOption
in interface SocketConnection
option
- socket option identifier (KEEPALIVE, LINGER, SNDBUF, RCVBUF,
or DELAY)
IllegalArgumentException
- if the option identifier is not valid
IOException
- if the connection was closedSocketConnection.setSocketOption(byte, int)
public String getLocalAddress() throws IOException
SocketConnection
The 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 SocketConnection
IOException
- if the connection was closed.ServerSocketConnection
public int getLocalPort() throws IOException
SocketConnection
getLocalPort
in interface SocketConnection
IOException
- if the connection was closed.ServerSocketConnection
public String getAddress() throws IOException
SocketConnection
getAddress
in interface SocketConnection
IOException
- if the connection was closed.public int getPort() throws IOException
SocketConnection
getPort
in interface SocketConnection
IOException
- if the connection was closed.
|
" 2013 FRC Java API " |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |