Get SWI-Prolog to communicate with another application

The error message is a bit obscure, but assuming that it means “file not found”, perhaps you can make the server work by:

C:\Program Files\swipl>swipl simple_server.pl --port=9999 --staticdir=/full/path/to/static

where full/path/to/ is wherever you’ve put the source file for simple_server.pl

An alternative is to cd to the directory that has simple_server.pl and then do:

\Program Files\swipl\swipl.exe simple_server.pl --port=9999 --staticdir=static

[Windows drives me crazy and I try to avoid it]

Thanks @peter.ludemann & @mjano314 . I’ll try your advice!

Some time ago, I ran my simple server on the Windows Subsystem for Linux (WSL) and it could communicate with a normal Windows browser (Chrome). But my Windows laptop is broken right now, so I don’t have a way of verifying that this still works (it should, of course).

What I don’t understand is why you get this error: Timeout in read from <stream>(0000013f7b324c20) instead of some kind of “can’t open file” error. Perhaps there’s a strange cascade of exception handling. When I try to reproduce this on Linux (by setting the --static option to a non-existent directory), I just get a failure message, nothing about read_util:read_line_to_codes/2. Did you enable some other debugging, to get this? (I tried putting a spypoint on http_files:http_reply_from_files/3, but that didn’t get anything)

I think that could be the choice of the folder where you downloaded and expanded Peter’s example repo that could make a difference. This morning on Windows 10 I did

C:\Users\Carlo\test\prolog>git clone https://github.com/kamahen/swipl-server-js-client.git
C:\Users\Carlo\test\prolog>cd swipl-server-js-client
C:\Users\Carlo\test\prolog\swipl-server-js-client>swipl simple_server.pl --port=9999 --staticdir=static
% static dir: static
% Started server at http://localhost:9999/
% Starting REPL ...
?-
% [Thread httpd@9999_2] [1] get / ...
% [Thread httpd@9999_2] [1] 301 moved(/static/simple_client.html); 395 bytes
% [Thread httpd@9999_4] [2] get /static/simple_client.html ...
% [Thread httpd@9999_4] [2] 200 file(text/html,c:/users/carlo/test/prolog/swipl-server-js-client/static/simple_client.html); 2,080 bytes
% [Thread httpd@9999_3] [3] get /static/simple_client.css ...
% [Thread httpd@9999_3] [3] 200 file(text/css,c:/users/carlo/test/prolog/swipl-server-js-client/static/simple_client.css); 426 bytes
% [Thread httpd@9999_5] [4] get /static/simple_client.js ...
% [Thread httpd@9999_5] [4] 200 file(text/javascript,c:/users/carlo/test/prolog/swipl-server-js-client/static/simple_client.js); 4,569 bytes
% [Thread httpd@9999_1] [5] get /static/favicon.ico ...
% [Thread httpd@9999_1] [5] 200 file(image/x-ico,c:/users/carlo/test/prolog/swipl-server-js-client/static/favicon.ico); 32,038 bytes
% [Thread httpd@9999_2] [6] post /json ...
% [Thread httpd@9999_2] [6] 200 OK (0.000 seconds; 1,880 bytes)

that is, it’s running fine out-of-the-box…

@CapelliC , I followed your example exactly and it is working now. The install folder was the problem. Thank you everyone!