Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.squawk.io.j2me.socket
Class Protocol

    java.lang.Object
      com.sun.squawk.io.ConnectionBase
          com.sun.squawk.io.j2me.socket.Protocol

All Implemented Interfaces:
  Connection, InputConnection, OutputConnection, SocketConnection, StreamConnection

    public class Protocol

extends ConnectionBase
implements SocketConnection

Connection to the J2ME socket API.

Version:
  1.0 1/16/2000

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

### isopen

    protected boolean isopen

  Input stream open flag

### osopen

    protected boolean osopen

  Output stream open flag

Constructor Detail

### Protocol

    public Protocol()

  default constructor used by GCF

### Protocol

    public Protocol(int fd)

  Open the connection

  Parameters:
    `fd` - the accepted socket handle

Method Detail

### open

    public Connection open(String protocol,
                           String name,
                           int mode,
                           boolean timeouts)
                    throws IOException

  Open the connection

  Specified by:
    `open` in class `ConnectionBase`
  Parameters:
    `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
  Returns:
    new connection
  Throws:
    `IOException`
    `ConnectionNotFoundException` - If the connection cannot be found.

### openInputStream

    public InputStream openInputStream()
                                throws IOException

  Returns an input stream for this socket.

  Specified by:
    `openInputStream` in interface `InputConnection`
  Overrides:
    `openInputStream` in class `ConnectionBase`
  Returns:
    an input stream for reading bytes from this socket.
  Throws:
    `IOException` - if an I/O error occurs when creating the input stream.

### openOutputStream

    public OutputStream openOutputStream()
                                  throws IOException

  Returns an output stream for this socket.

  Specified by:
    `openOutputStream` in interface `OutputConnection`
  Overrides:
    `openOutputStream` in class `ConnectionBase`
  Returns:
    an output stream for writing bytes to this socket.
  Throws:
    `IOException` - if an I/O error occurs when creating the output stream.

### close

    public void close()
               throws IOException

  Close the connection.

  Specified by:
    `close` in interface `Connection`
  Overrides:
    `close` in class `ConnectionBase`
  Throws:
    `IOException` - if an I/O error occurs when closing the connection.

### openDataInputStream

    public DataInputStream openDataInputStream()
                                        throws IOException

  Open and return a data input stream for a connection.

  Specified by:
    `openDataInputStream` in interface `InputConnection`
  Overrides:
    `openDataInputStream` in class `ConnectionBase`
  Returns:
    An input stream
  Throws:
    `IOException` - If an I/O error occurs

### openDataOutputStream

    public DataOutputStream openDataOutputStream()
                                          throws IOException

  Open and return a data output stream for a connection.

  Specified by:
    `openDataOutputStream` in interface `OutputConnection`
  Overrides:
    `openDataOutputStream` in class `ConnectionBase`
  Returns:
    An input stream
  Throws:
    `IOException` - If an I/O error occurs

### setSocketOption

    public void setSocketOption(byte option,
                                int value)
                         throws IllegalArgumentException,
                                IOException

  Description copied from interface: `SocketConnection`
  Set a socket option for the connection.

  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.

  Specified by:
    `setSocketOption` in interface `SocketConnection`
  Parameters:
    `option` - socket option identifier (KEEPALIVE, LINGER, SNDBUF, RCVBUF, or DELAY)
    `value` - numeric value for specified option
  Throws:
    `IllegalArgumentException` - if the value is not valid (e.g., negative value) or if the option identifier is not valid
    `IOException` - if the connection was closed
  See Also:
    `SocketConnection.getSocketOption(byte)`

### getSocketOption

    public int getSocketOption(byte option)
                        throws IllegalArgumentException,
                               IOException

  Description copied from interface: `SocketConnection`
  Get a socket option for the connection.

  Specified by:
    `getSocketOption` in interface `SocketConnection`
  Parameters:
    `option` - socket option identifier (KEEPALIVE, LINGER, SNDBUF, RCVBUF, or DELAY)
  Returns:
    numeric value for specified option or -1 if the value is not available.
  Throws:
    `IllegalArgumentException` - if the option identifier is not valid
    `IOException` - if the connection was closed
  See Also:
    `SocketConnection.setSocketOption(byte, int)`

### getLocalAddress

    public String getLocalAddress()
                           throws IOException

  Description copied from interface: `SocketConnection`
  Gets the local address to which the socket is bound.

  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")`

  Specified by:
    `getLocalAddress` in interface `SocketConnection`
  Returns:
    the local address to which the socket is bound.
  Throws:
    `IOException` - if the connection was closed.
  See Also:
    `ServerSocketConnection`

### getLocalPort

    public int getLocalPort()
                     throws IOException

  Description copied from interface: `SocketConnection`
  Returns the local port to which this socket is bound.

  Specified by:
    `getLocalPort` in interface `SocketConnection`
  Returns:
    the local port number to which this socket is connected.
  Throws:
    `IOException` - if the connection was closed.
  See Also:
    `ServerSocketConnection`

### getAddress

    public String getAddress()
                      throws IOException

  Description copied from interface: `SocketConnection`
  Gets the remote address to which the socket is bound. The address can be either the remote host name or the IP address(if available).

  Specified by:
    `getAddress` in interface `SocketConnection`
  Returns:
    the remote address to which the socket is bound.
  Throws:
    `IOException` - if the connection was closed.

### getPort

    public int getPort()
                throws IOException

  Description copied from interface: `SocketConnection`
  Returns the remote port to which this socket is bound.

  Specified by:
    `getPort` in interface `SocketConnection`
  Returns:
    the remote port number to which this socket is connected.
  Throws:
    `IOException` - if the connection was closed.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"