Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: Read/Load/Eval/Compile   [Contents][Index]


6.18.13 REPL Servers

The procedures in this section are provided by

(use-modules (system repl server))

When an application is written in Guile, it is often convenient to allow the user to be able to interact with it by evaluating Scheme expressions in a REPL.

The procedures of this module allow you to spawn a REPL server, which permits interaction over a local or TCP connection. Guile itself uses them internally to implement the --listen switch, Command-line Options.

Scheme Procedure: make-tcp-server-socket [#:host=#f] [#:addr] [#:port=37146]

Return a stream socket bound to a given address addr and port number port. If the host is given, and addr is not, then the host string is converted to an address. If neither is given, we use the loopback address.

Scheme Procedure: make-unix-domain-server-socket [#:path="/tmp/guile-socket"]

Return a UNIX domain socket, bound to a given path.

Scheme Procedure: run-server [server-socket]
Scheme Procedure: spawn-server [server-socket]

Create and run a REPL, making it available over the given server-socket. If server-socket is not provided, it defaults to the socket created by calling make-tcp-server-socket with no arguments.

run-server runs the server in the current thread, whereas spawn-server runs the server in a new thread.

Scheme Procedure: stop-server-and-clients!

Closes the connection on all running server sockets.

Please note that in the current implementation, the REPL threads are cancelled without unwinding their stacks. If any of them are holding mutexes or are within a critical section, the results are unspecified.