com.sun.cdc.io.j2me.serversocket
Class Protocol

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by java.io.DataOutputStream
              extended by com.sun.cdc.io.GeneralBase
                  extended by com.sun.cdc.io.ConnectionBase
                      extended by com.sun.cdc.io.j2me.serversocket.Protocol
All Implemented Interfaces:
ConnectionBaseInterface, DataInput, DataOutput, Connection, ServerSocketConnection, StreamConnectionNotifier

public class Protocol
extends ConnectionBase
implements StreamConnectionNotifier, ServerSocketConnection

StreamConnectionNotifier to the Palm Server Socket API.


Field Summary
 
Fields inherited from class java.io.DataOutputStream
written
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
Protocol()
           
 
Method Summary
 StreamConnection acceptAndOpen()
          Returns a GenericConnection that represents a server side socket connection
protected  void checkPermission(int port)
           
 void close()
          Close the connection.
 String getLocalAddress()
          Gets the local address to which the socket is bound.
 int getLocalPort()
          Returns the local port to which this socket is bound.
 void open()
          Open the connection to an arbitrary system selected port and address
 void open(String name, int mode, boolean timeouts)
          Open the connection
 
Methods inherited from class com.sun.cdc.io.ConnectionBase
openDataInputStream, openDataOutputStream, openInputStream, openOutputStream, openPrim
 
Methods inherited from class com.sun.cdc.io.GeneralBase
flush, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skip, skipBytes, write, write
 
Methods inherited from class java.io.DataOutputStream
size, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 
Methods inherited from class java.io.FilterOutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.io.DataOutput
write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 

Constructor Detail

Protocol

public Protocol()
Method Detail

checkPermission

protected void checkPermission(int port)

open

public void open(String name,
                 int mode,
                 boolean timeouts)
          throws IOException
Open the connection

Specified by:
open in class ConnectionBase
Parameters:
name - the target for the connection
writeable - a flag that is true if the caller expects to write to the connection.
timeouts - A flag to indicate that the called wants timeout exceptions

The name string for this protocol should be: "

Throws:
ConnectionNotFoundException - If the connection cannot be found.
IOException - If some other kind of I/O error occurs.

open

public void open()
          throws IOException
Open the connection to an arbitrary system selected port and address

Throws:
IOException

acceptAndOpen

public StreamConnection acceptAndOpen()
                               throws IOException
Returns a GenericConnection that represents a server side socket connection

Specified by:
acceptAndOpen in interface StreamConnectionNotifier
Returns:
a socket to communicate with a client.
Throws:
IOException - if an I/O error occurs when creating the input stream.

close

public void close()
           throws IOException
Close the connection.

Specified by:
close in interface Connection
Overrides:
close in class GeneralBase
Throws:
IOException - if an I/O error occurs when closing the connection.
See Also:
FilterOutputStream.flush(), FilterOutputStream.out

getLocalAddress

public String getLocalAddress()
                       throws IOException
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 reassignment.

The local hostname (if available) can be accessed from System.getProperty("microedition.hostname")

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

getLocalPort

public int getLocalPort()
                 throws IOException
Returns the local port to which this socket is bound.

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