[racket] Question on networking
I didn't know that, I'm just trying to see how things work with networking.
The TCP question was unrelated, i wanted to know if with that echo-server i needed to make a client that knew my IP adress to connect to it.
I'd have to configure the same things i needed to change for the webpage i suppose?
Also, my main question, is there anyway i can make a page like http://www.hellofriends.com and if someone typed that in a browser they'd be redirected to my page from my computer? or for that i need to pay for a server?
Thanks for the answers
Subject: Re: [racket] Question on networking
From: clements at brinckerhoff.org
Date: Fri, 22 Mar 2013 13:02:49 -0700
CC: users at racket-lang.org
To: tomcoiro at hotmail.com
On Mar 21, 2013, at 7:57 PM, Tomás Coiro 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 likewww.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"))))
On the Racket side, making your server open to the web is actually quite easy:
#lang racket
(require web-server/servlet-env web-server/http/xexpr)
;; A "hello world" web server(define (start request) (response/xexpr '(html (body "Hello World"))))
(serve/servlet start #:listen-ip #f #:port 27803)
The #:listen-ip #f tells Racket that you want to accept connections from any machine, not just from your own.
There's no need to deal with tcp-level stuff.
Having said this, the real challenge may be in routing your friend's request to your computer. That is: if you want your friend's request to come to your computer, you need an IP address that your friend's computer can use to reach you.
If you're like most people, your computer is connected to an ISP (internet service provider) through a router. To find out what your IP address is, try visiting a site like "www.dnsstuff.com". At the top, in teeny tiny letters, it will tell you your IP address; it will look like four numbers separated by periods. Suppose it's 62.241.212.42. (I just made that up.) Since your web server will be running on port 27803 (that's what I put in the racket program, above), your friend will need to visit
http://62.241.212.42:27803
to get to your server. Note that most ISPs occasionally change your IP address; if you grab it now, it may not still be accurate next week.
But wait! If you try this, chances are high that it won't work. That's because most people are behind a router, and maybe one or more firewalls as well. In order to fix this, you need to open "pinholes" through your routers and firewalls to ensure that requests for this port that arrive at your house get properly routed to your computer. This will probably involve configuring your router and/or your machine's firewall.
To summarize: from the Racket standpoint, it's easy; however, you're probably going to have to do a bunch of work to allow your friend to reach your computer.
And, of course, apologies if you already knew all of this.
Best,
John Clements
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130322/0c5226bf/attachment.html>