[erlang-questions] jinterface (was: otp.net)

Serge Aleynikov saleyn@REDACTED
Sat Oct 4 07:32:55 CEST 2008


I tried a similar test using jinterface to see if it's possible to 
monitor processes running on a Java node and ran into the same failure.

Can anyone explain what's wrong?

(server@REDACTED)10> {test, client@REDACTED} ! {self(), hello}.
{<0.45.0>,hello}
(server@REDACTED)11> f(), {Pid, _} = receive M -> M end.
{<5979.1.0>,hello}
(server@REDACTED)12> erlang:monitor(process, Pid).
** exception error: bad argument
      in function  erlang:monitor/2
         called as erlang:monitor(process,<5979.1.0>)



The corresponding java node was implemented using code below:


import com.ericsson.otp.erlang.*;

public class test {
	public static void main (String args[]) {
		System.out.println ("Hello World!");

         try {
             OtpSelf self = new OtpSelf("client", "abc123");
             OtpPeer other = new OtpPeer("server");
             OtpConnection connection = self.connect(other);

             connection.sendRPC("erlang","date",new OtpErlangList());
             OtpErlangObject received = connection.receiveRPC();
             System.out.println("erlang:date() -> " + received + "\n");

             OtpErlangObject o;
             OtpErlangTuple msg;
             OtpErlangPid from;

             while (true) {
                 try {
                     o = connection.receive();
                     if (o instanceof OtpErlangTuple) {
                         msg = (OtpErlangTuple)o;
                         from = (OtpErlangPid)(msg.elementAt(0));
                         connection.send(from, new OtpErlangTuple(
                             new OtpErlangObject[] {
                                 self.pid(),
                                 msg.elementAt(1)
                             }
                         ) );
                     }
                 }
                 catch (Exception e) {
                     System.out.println("" + e);
                 }
             }
         } catch (Exception e) {
             System.out.println("" + e);
         }
     }
}


Serge Aleynikov wrote:
> While playing with the otp.net project for the past several days I ran 
> into one problem that I can't quite explain.  I am starting a .NET node
> (saleyn@REDACTED) and connecting to a regular Erlang node 
> (a@REDACTED), then send a Pid from .NET to Erlang and try to set up a 
> monitor.  The monitor call fails with badarg:
> 
> (a@REDACTED)2> register(test, self()).
> true
> (a@REDACTED)3> nodes(hidden).
> [saleyn@REDACTED]
> (a@REDACTED)4> f(M), M = receive M -> M end.
> <5852.1.0>
> (a@REDACTED)5> M ! {hello, self()}.
> {hello,<0.50.0>}
> (a@REDACTED)6> erlang:monitor(process, M).
> ** exception error: bad argument
>       in function  erlang:monitor/2
>          called as erlang:monitor(process,<5852.1.0>)
> (a@REDACTED)7>
> 
> I am able to send messages back and forth between two nodes and verify 
> their delivery, but don't understand why the monitor call would fail. 
> Does anyone have a clue?
> 
> Serge
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list