triska / the-power-of-prolog

Introduction to modern Prolog
https://www.metalevel.at/prolog
1.23k stars 76 forks source link

scryer-prolog 0.0.0.0 IP address but not localhost? #21

Closed yuis-ice closed 4 years ago

yuis-ice commented 4 years ago

I'd like to run your book from docker for a reason. and I need to access it from external browser, like 192.168.0.183:6022/prolog., not localhost:6022/prolog. while running the command scryer-prolog -g "server(6012)" server.pl , it looks it is running on localhost, as below lsof output. so I'd like to know is there some way to run scryer-prolog -g "server(6012)" server.pl with specified 0.0.0.0 IP address. Thanks.

root@324e3f0b47c4:/the-power-of-prolog# lsof -n | grep TCP | grep LISTEN
scryer-pr 8864 root    3u  IPv4 1120003      0t0     TCP 127.0.0.1:6022 (LISTEN)
yuis-ice commented 4 years ago

solved.

I changed server.pl as following

server(Port) :-
        socket_server_open('127.0.0.1':Port, Socket),
        accept_loop(Socket).
server(Port) :-
        socket_server_open('0.0.0.0':Port, Socket),
        accept_loop(Socket).

and scryer-prolog -g "server(6012)" server.pl as usual

triska commented 4 years ago

Thank you for this workaround!

I have added 759057f20e0304f23780ddbf20a61a93c15e25da so that the IP can also be specified on the command line, please have a look!