[racket] Help with sockets.
One thing you might need to think about is buffering. Here's another
example of a Racket server that doubles up the bytes it reads:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang racket
(define listener (tcp-listen 12346 4 #t))
(let doubler-server ()
(define-values (in out) (tcp-accept listener))
(thread (λ () (let loop ()
(define b (read-byte in))
(cond
[(eof-object? b)
(close-output-port out)]
[else
(write-byte b out)
(write-byte b out)
(flush-output out)
(loop)]))))
(doubler-server))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
The Python client can stay the same.
The use of flush-output is there because we want to flush the buffer
and send the buffered bytes over the network.