source: project/wiki/Connecting to a REPL via sockets @ 1620

Last change on this file since 1620 was 1620, checked in by felix winkelmann, 14 years ago

added code snippets from coop

File size: 885 bytes
Line 
1If you want to connect to an interactive read-eval-print-loop via tcp
2sockets, this might be helpful:
3
4 (use tcp)
5
6 (define (remote-repl #!optional (port 9999))
7   (let*-values (((x) (tcp-listen port))
8                 ((i o) (tcp-accept x)))
9     (current-input-port i)
10     (current-output-port o)
11     (current-error-port o)
12     ;(when (provided? 'debug) (set! ##dbg#command-output-port o))   ; in case you use the debug egg
13     (repl)))
14
15 (remote-repl)
16
17It is important to start the listening executable with the {{-:c}}
18runtime-option, to force output of the prompt (even if not communicating
19with a terminal port).
20
21If you compile and run this program, you should be able to connect
22to it via {{telnet}}:
23
24 % telnet localhost 9999
25 Trying ::1...
26 telnet: connect to address ::1: Connection refused
27 Trying 127.0.0.1...
28 Connected to localhost.
29 Escape character is '^'.
30 #;> 123
31 123
32 #;>
Note: See TracBrowser for help on using the repository browser.