<html><head><base href="x-msg://146/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Mar 21, 2013, at 7:57 PM, Tomás Coiro wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="hmmessage" style="font-size: 12pt; font-family: Calibri; "><div dir="ltr">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.<br><br><br>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<a href="www.hello.com?" target="_blank"></a><a href="www.hello.com?" target="_blank"></a><a href="www.hello.com?" target="_blank"></a><a href="www.hello.com" target="_blank">www.hello.com</a> ? Can I do it from my computer? <br><br><br>#lang web-server/insta<br><br>;; A "hello world" web server<br>(define (start request)<br>(response/xexpr<br>'(html<br>(body "Hello World"))))<br></div></div></span></blockquote><div><br></div><div>On the Racket side, making your server open to the web is actually quite easy:</div><div><br></div><div><div>#lang racket</div><div><br></div><div>(require web-server/servlet-env</div><div> web-server/http/xexpr)</div><div><br></div><div>;; A "hello world" web server</div><div>(define (start request)</div><div> (response/xexpr</div><div> '(html</div><div> (body "Hello World"))))</div><div><br></div><div>(serve/servlet start</div><div> #:listen-ip #f</div><div> #:port 27803)</div><div><br></div><div>The #:listen-ip #f tells Racket that you want to accept connections from any machine, not just from your own.</div></div><div><br></div><div>There's no need to deal with tcp-level stuff.</div><div><br></div><div>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.</div><div><br></div><div>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 "<a href="http://www.dnsstuff.com">www.dnsstuff.com</a>". 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<b>. </b>(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</div><div><br></div><div>http://62.241.212.42:27803</div><div><br></div><div>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.</div><div><br></div><div>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. </div><div><br></div><div>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.</div><div><br></div><div>And, of course, apologies if you already knew all of this.</div><div><br></div><div>Best,</div><div><br></div><div>John Clements</div><div><br></div><div><br></div><div><br></div></div></body></html>