[racket] Question on networking

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Fri Mar 22 07:52:57 EDT 2013

At the most basic level, web-server/insta can't be used for a server
because (a) the port is non-deterministically chosen, so it isn't
reliable as a server and (b) it calls the TCP listening creation call
such that it only listens to localhost. When you use serve/servlet
instead, you can set the port to something particular and you can set
the listening to listen to all IPs.


On Thu, Mar 21, 2013 at 8:57 PM, Tomás Coiro <tomcoiro at hotmail.com> wrote:
> I've been seeing the examples of Racket to make a server, and although I
> learned a lot, I'd love to know how to actually launch it so, for example, a
> friend can see my page from his house.
> For the best example, let's say i have the Hello World server, what changes
> do i need to make so someone can access it from a browser? can I use a
> webpage like www.hello.com ? Can I do it from my computer?
> #lang web-server/insta
> ;; A "hello world" web server
> (define (start request)
> (response/xexpr
> '(html
> (body "Hello World"))))
> Also, to make something like this work between 2 different computers over
> the internet:
> (define listener (tcp-listen 12345))
> (let echo-server ()
> (define-values (in out) (tcp-accept listener))
> (thread (lambda () (copy-port in out)
> (close-output-port out)))
> (echo-server))
> Would i need to write a client that connects to the servers IP and to the
> specified port?
> Thanks in advance.
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.