[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tcp-listen
On Mon, Jan 07, 2002 at 11:22:07AM -0500, Eli Barzilay wrote:
> On Jan 7, Wojciech Sobczuk wrote:
> > hey,
> >
> > it would be nice to have an option to tcp-listen on a single IP not
> > all (as it is now). it's probably a simple change..
>
> But you can easily do it in Scheme:
well, i like to have the flexibility to be able to listen on a single ip, and
i'm sure it would be used by more people.
for example, i'd like to have apache listen on one ip and port 80, and
a scheme web server on another ip of the same host on port 80 too.
Wojtek
>
> (define (connection)
> (printf ">>> ~s~%" (read-line)))
> (define (server)
> (define listener (tcp-listen 9999 1))
> (let loop ()
> (let*-values (((i o) (tcp-accept listener))
> ((_ ip) (tcp-addresses i)))
> (when (equal? ip "127.0.0.1")
> (parameterize ((current-input-port i)
> (current-output-port o))
> (connection)))
> (close-input-port i)
> (close-output-port o))
> (loop)))
>
> or maybe you want to deny connections?
>
> --
> ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
> http://www.barzilay.org/ Maze is Life!