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

Last change on this file since 1628 was 1628, checked in by svnwiki, 14 years ago

Changes applied for Mario (201.47.215.169) through svnwiki:

Formated as Scheme code.

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