If you want to connect to an interactive read-eval-print-loop via tcp sockets, this might be helpful:

 (use tcp)

 (define (remote-repl #!optional (port 9999))
   (let*-values (((x) (tcp-listen port))
		 ((i o) (tcp-accept x)))
     (current-input-port i)
     (current-output-port o)
     (current-error-port o) 
     ;(when (provided? 'debug) (set! ##dbg#command-output-port o))   ; in case you use the debug egg
     (repl)))

 (remote-repl)

It is important to start the listening executable with the -:c runtime-option, to force output of the prompt (even if not communicating with a terminal port).

If you compile and run this program, you should be able to connect to it via telnet:

% telnet localhost 9999
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^'.
#;> 123
123
#;>