global_name_server question.
Jon Larsson
jon@REDACTED
Thu Jun 3 03:07:38 CEST 1999
Hi Vladimir,
I tried your program and it works fine for me. In your last email you
correctly used global:register_name(eh,P) instead of the register(eh,P)
in the original program. I have attached my erl file, the C program and
the makefile below. I get the following result:
universe_104% erl -sname test -setcookie bla
Erlang (BEAM) emulator version 47.4.1
Eshell V47.4.1 (abort with ^G)
(test@REDACTED)1> test:start().
Starting the receiver.
yes
(test@REDACTED)2> global:registered_names().
[eh]
And when I run the C program:
universe_33% ./erl_reg_send
4,1
Cheers,
Jon Larsson
--
Erl file:
%%-------------------------------------------------
-module(test).
-export([start/0,receiver/0]).
%%-------------------------------------------------
start() ->
P = spawn(test, receiver, []),
io:fwrite("Starting the receiver.~n"),
global:register_name(eh, P).
%%--------------------------------------------------
receiver() ->
receive
stop ->
io:format("Stop.~n");
Message ->
io:format("Recv: ~w~n", [Message]),
receiver()
end.
%%---------------------------------------------------
C file:
*****************************************************
#include "erl_interface.h"
#include "ei.h"
int main(int argc, char **argv) {
int sockfd;
char **names;
int count;
erl_init(NULL, 0);
erl_connect_init(42, "bla", 0);
sockfd = erl_connect("test@REDACTED");
names = erl_global_names(sockfd, &count);
printf("%d,%d\n", sockfd, count);
erl_close_connection(sockfd);
}
*****************************************************
Makefile:
FILES = erl_reg_send.o
INCFLAGS = -I/opt/erlang-47.4.1/lib/erlang/usr/include
LIBFLAGS = -L/opt/erlang-47.4.1/lib/erlang/usr/lib
CFLAGS = $(INCFLAGS) $(LIBFLAGS)
all: $(FILES)
$(LINK.c) -o erl_reg_send $< -lerl_interface -lei -lnsl -lsocket -lresolv
More information about the erlang-questions
mailing list