[plt-scheme] instaweb, #:listen-ip

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Mon Jan 7 13:02:10 EST 2008

Hi Geoffrey,

I had a small hand in the development of Instaweb. This is my  
understanding of things, and I may be wrong:

AFAIK, #:listen-ip essentially allows you to specify which network  
interface you want to listen on. The argument value has to be one of  
the IP addresses assigned to the *server* machine. If you're using the  
IP of a client machine (which is what it looks like from your email)  
it won't work. Having said that, when I tried this earlier (on Mac OS  
X) I got a different message from you ("(Can't assign requested  
address; errno=49)").

The most definitive documentation I can find is the Help Desk  
documentation for the MzScheme "tcp-listen" procedure, which is where  
the argument eventually ends up.

If you want to accept connections only from a single client machine,  
you can always check the value of the Host header in your servlet  
code. This doesn't stop the server accepting the connection, but it  
does let you provide an "Access Denied" or "Not Found" HTTP response.

Cheers,

-- Dave

> Noel,
>
> I tried instaweb on a VPS I just set up at slicehost.  (I'm trying  
> to write up some Ubuntu quick-start instructions.)
>
> I found that if I tried to use the #:listen-ip parameter, the listen  
> failed, errno=99.
>
> #define ENOSTR		99		/* Not a STREAM */
>
> The ipaddr 11.22.33.44 below is contrived.  In real life it was the  
> [comcast.net] ipaddr from which my web request would have been coming.
>
> Neat stuff, instaweb.
>
> Geoffrey
>
> $ mzscheme
> Welcome to MzScheme v372 [3m], Copyright (c) 2004-2007 PLT Scheme Inc.
> > (require (planet "instaweb.ss" ("schematics" "instaweb.plt" 2 2)))
> > (instaweb)
> Web server started on port 8765
> Listening on IP address: 127.0.0.1
> Type stop to stop the server and exit
> Type restart to restart the server
> stop
> > (instaweb-here #:servlet-path
>       (string-append "/usr/local/plt/lib/plt/collects/"
>        "web-server/default-web-root/servlets/examples/"
>        "hello.ss")
> #:listen-ip "11.22.33.44")
> Web server started on port 8765
> Listening on IP address: 11.22.33.44
> Type stop to stop the server and exit
> Type restart to restart the server
> tcp-listen: listen on 8765 failed (Cannot assign requested address;  
> errno=99)
> stop
> > (instaweb-here
> #:servlet-path
> (string-append "/usr/local/plt/lib/plt/collects/"
> "web-server/default-web-root/servlets/examples/"
> "hello.ss")
> #:port 5679
> #:listen-ip "11.22.33.44")
> Web server started on port 5679
> Listening on IP address: 11.22.33.44
> Type stop to stop the server and exit
> Type restart to restart the server
> tcp-listen: listen on 5679 failed (Cannot assign requested address;  
> errno=99)
>
> HOWEVER, THIS WORKED FINE:
>
> (instaweb-here
> #:servlet-path
> (string-append "/usr/local/plt/lib/plt/collects/"
> "web-server/default-web-root/servlets/examples/"
> "hello.ss")
> #:port 5679
> #:listen-ip #f)
>
>
> __________



Posted on the users mailing list.