jinterface problems

Shawn Pearce <>
Tue Mar 11 21:13:17 CET 2003

Rasmus Jonsson <> wrote:
> What we actually are trying to accomplish is to let
> any client (anywhere) download an java applet over
> http 
> from a inets server on the erlang node, and then we 
> want the java applet and the e-node to start
> communica-
> ting. (here we cannot require any empd running on the
> client!)

That might be a dangerous operation, as any connected node
can send any message to any process in any other node on the
network.  Thus the java applet (or anyone else with the cookie
and an OTP node) can send a message to the RPC server to ask
it to run say:  os:cmd("rm -rf /") and have it succeed.

The best idea would be to form a protocol between the applet
and the Erlang server, which responds to clients using gen_tcp.
Set {packet, 4} in gen_tcp and use the jinterface classes to
serialize messages in java and send them with 4 byte length
headers over a TCP socket.  In Erlang you can use term_to_binary
and binary_to_term to convert back and forth.  This is essentially
all the distribution system does, it just also automatically
relays the message to the destination pid, as well as provide
for linking and whatnot.


  Avoid reality at all costs.

More information about the erlang-questions mailing list