I had a quick look. First of all, you need to use expects_dialect as a
directive, so you start with:
:- expects_dialect(sicstus).
:- use_module(library(sockets)).
That doesn't fis this particular problem (but does for other compatibility
issues). Then, this emulation was written for a SICStus 3 program. That
runs using it, but don't ask full compatibility. Before you can hand a
SWI-Prolog socket to wait_for_input/3, you have to use tcp_open_socket/2
to get a stream. If you add that to service_socket/1, it actually waits
for a connection, to stumble on the non-existing service_stream/1 when
connecting. I don't know what that does. The typical way to deal with
sockets in SWI-Prolog is by means of threads.
I think you need a short study of SWI-Prolog's library(socket) and see
how to map the functionality you need.
Success --- Jan