JoCaml: problems with remote connection

(Probably enough to know the Unix library to answer this, so please read it if you don't know JoCaml.)

I have two programs in JoCaml . A server ready to return the square of a number to port 12345

(* p.ml *)
def f (x) =
        print_string ("["^string_of_int(x)^"] "); flush stdout;
        reply x*x to f
in Join.Ns.register Join.Ns.here "square" f
;;
let wait =
        def x () & y () = reply to x
        in x
let main =
        Join.Site.listen (Unix.ADDR_INET (Join.Site.get_local_addr(), 12345));
        wait()

and a client ready to use the square server function

(* q.ml *)
let server =
        let server_addr = Unix.gethostbyname "192.168.0.10" in
        Join.Site.there (Unix.ADDR_INET(server_addr.Unix.h_addr_list.(0),12345))
let ns = Join.Ns.of_site server
let sqr = (Join.Ns.lookup ns "square": int -> int)
let _ = Printf.printf "%d\n" (sqr 3)

All this works fine if two programs work on the same computer. But my goal is to put them on two different cars. Thus, the IP address must become another public IP address. Since I only have one machine, to check this, I decided to run two programs on this machine and instead of 192.168.0.10 write the public IP address of my machine instead. Unfortunately, it does not work, connection time.

Any ideas?

[Changed]

More about the problem

, , , JoCaml, , . , , ​​ P2P- JoCaml, , , . , , - "" q.ml, .

. . , : , ( , ). P2P . ( , , - , .) -, . , ( ). (1-1), . , , , , , , , P2P. .

:

  • P2P- (, 1-1 )
  • .
  • ,

, 2. , P2P?

(, P2P - . , -, , - P2P JoCaml. , .)

+3
2

( , IP-, , JoCaml.)

- IP-, , IP-. ( IP- , .) , .

. , , . 192.168.0.10 - . . , (NAT) . NAT , .

, , , : A - , C - , , R - 1.2.3.4 - , IP- (, ):

C [5.6.7.8] ←———→ [1.2.3.4] R [192.168.0.1] ←———→ [192.168.0.10] A

C A, 192.168.0.10, . C A, 1.2.3.4, R , 1.2.3.4 A ( R TCP UDP-, ). A , 1.2.3.4 : , , R, .

- , , - , , , , . , Jocaml IP- ..

, : . - , , JoCaml. ssh . ( ) , , SSH. : , . , , , ( , , ); JoCaml ( , ).

+2

Unix.ADDR_INET(server_addr.Unix.h_addr_list.(0), 12345)

, , loopback. , .

Unix.ADDR_INET (Unix.inet_addr_of_string "0.0.0.0", 12345)

. , .

0

Source: https://habr.com/ru/post/1796605/


All Articles