Interface IMCServerConnection

All Superinterfaces:
javax.microedition.io.Connection, javax.microedition.io.StreamConnectionNotifier

public interface IMCServerConnection
extends javax.microedition.io.StreamConnectionNotifier

This interface defines a server connection for the Inter-MIDlet Communication (IMC) protocol. A server connection is obtained through Connector.open() with the server connection URI string according to the BNF syntax defined below.

The acceptAndOpen() method returns an IMCConnection instance. In addition to the normal behavior of a StreamConnection, the IMCConnection allows the IMC server to get the requested server version and the client MIDlet's identity. The call to IMCServerConnection.acceptAndOpen() is synchronous and the current thread will be blocked until a client connection arrives or some exception is thrown. If multiple connection requests arrive at the same time, the remaining connections will be queued up by the implementation to be returned by the next acceptAndOpen() call.

In the connection URI string, the IMC server can specify authorization requirements for the IMC clients. If authorization is required (by specifying authmode=true in the connection URI), only the connection requests from access authorized MIDlets will be accepted. See Application Level Access Authorization for more details. If authmode=false is specified or if this does not appear in the connection URI, the server connection will accept connection from any client that meets the name and version requirements.

BNF Format for Connector.open() string

The IMC server connection URIs must conform to the BNF syntax defined below. If the IMC server connection URI does not conform to this syntax, an IllegalArgumentException is thrown.

<server_conn_string> ::= "imc://" ":" <server name> ":" <server version> ";" [<authmode>]
<server name> ::= IMC server name following the class naming syntax
<server version> ::= version of the IMC server. Backward compatibility is assumed. Versioning follows the format defined for the MIDlet-Version attribute.
<authmode> ::= authmode=true|false

The IMC server connection URI is used for the connection URL for registering a MIDlet for auto launch (as part of the MIDlet-Push-<n> attribute). The AllowedSender is either "*" or MIDlet_UID. See IMCConnection for description of MIDlet_UID. IMC Servers may also be registered dynamically using the PushRegistry.registerConnection() API. Here is an example on registering a IMC Server at installation time,

 MIDlet-Push-1:imc://:com.foo.barServer:1.0;authmode=true, MyIMCServer, *

An IMC server is assumed to be always backward compatible with earlier versions. An IMC client can be connected to a server if the version requested is same or lower than the declared version in the server connection string. An IMC server can get the requested server version of an established connection through IMCConnection.getRequestedServerVersion() method and respond to the client accordingly based on the version requested.


      IMCServerConnection serverConn = (IMCServerConnection)Connector.open(

      while(true) {
          IMCConnection conn = (IMCConnection) serverConn.acceptAndOpen();

          try {
              String requestedVersion = conn.getRequestedServerVersion();
              DataInputStream requestData = conn.openDataInputStream();
              DataOutputStream responseData = conn.openDataOutputStream();

              // read request data from requestData input stream
              int requestType = requestData.readInt();

              // Handle the request

              // write response into the output stream
              responseData.writeUTF("Hello! This is the barServer");
          } finally {

MIDP 3.0

Method Summary
 java.lang.String getName()
          Get the name of the IMC server
 java.lang.String getVersion()
          Get the version of the IMC server
Methods inherited from interface javax.microedition.io.StreamConnectionNotifier
Methods inherited from interface javax.microedition.io.Connection

Method Detail


java.lang.String getName()
Get the name of the IMC server

The name of the IMC server


java.lang.String getVersion()
Get the version of the IMC server

The version of the IMC server


Send a comment or suggestionVersion 3.0 of Mobile Information Device Profile Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries. Copyright 2002-2009 Motorola Inc. Portions copyright 1993-2002 Sun Microsystems, Inc. and Motorola, Inc. All Rights Reserved.