Java Reference
In-Depth Information
On the other side, there could be a native Symbian C++ application,
a Flash Lite IPC client that uses ActionScript or a Python script. The
IPC server code can be implemented in any run-time environment that
supports accepting incoming TCP connections. 13
For the sake of providing a reference implementation, here is an IPC
server-side connection in Java ME:
public class IpcServerConnection extends IpcConnection {
private final SocketConnection sc;
private IpcServerConnection(SocketConnection sc) throws IOException {
super(sc.openInputStream(), sc.openOutputStream()); = sc;
} public static IpcServerConnection openConnection(int ipcServerPort)
throws IOException {
ServerSocketConnection ssc =
SocketConnection sc = (SocketConnection) ssc.acceptAndOpen();
// TODO: use sc.getAddress() to ensure only local connections are
// handled
return new IpcServerConnection(sc);
// IPC operations
public IpcCommand receiveCommand() throws IOException {
return new IpcCommand(super.receive());
} public void sendResponse(IpcResponse response) throws IOException {
Opening a TCP port on your device is potentially a security hole. You
should, therefore, apply any methods required to ensure authorization of
incoming connections (e.g., accept incoming connections only from the
device itself).
An additional workaround that could be considered is a somewhat
more primitive form of communication. The passed information is put
into a file (using JSR-75, FileConnection) at a known location and is
polled on the other side. Obviously, this is not a suitable solution for
the majority of cases, which require either JNI or IPC. However, it is an
additional option for passing a message in an unreliable protocol.
There are obvious downsides to using this solution, such as breaking
platform portability and the need to manage and maintain both Java and
native support. However, TCP can be used to invoke native functionality
that is not available through Java APIs or to provide IPC between a
MIDlet and an application running in another process. In some cases,
13 Of course, the Java application may be the client and the other process may be the
Search WWH ::

Custom Search