[racket] Help with sockets.

From: Danny Yoo (dyoo at hashcollision.org)
Date: Tue Apr 22 16:34:22 EDT 2014

This should just work.


Can you show what code you're doing?


For example, given the following echo-server written in Racket,

;;;;;;;;;;;;;;;;;;;;
#lang racket
(define listener (tcp-listen 12345))
(let echo-server ()
  (define-values (in out) (tcp-accept listener))
  (thread (λ () (copy-port in out) (close-output-port out)))
  (echo-server))
;;;;;;;;;;;;;;;;;;;;



then the following interaction in Python shows that this is doing something:

###########################################
>>> import socket
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> s.connect(('localhost', 12345))
>>> s.send("hello")
5
>>> s.recv(500)
'hello'
###########################################


Posted on the users mailing list.