[racket] Using get-pure-port

From: Shogo Yamazaki (moquo2.718 at gmail.com)
Date: Thu Aug 18 15:41:25 EDT 2011

Thanks for your help.
The way you suggested worked for me.

By the way, I found that adding a line to the definition of
http-pipe-data in url-unit.rkt might resolve my problem either.
But I hardly understand what I'm doing.

(define (http-pipe-data chunked? ip op)
  (if chunked?
      (http-pipe-chunk ip op)
        (copy-port ip op)
        (close-input-port ip) ;### I added this line ###
        (flush-output op)
        (close-output-port op))))

Shogo Yamazaki

2011/8/19 Danny Yoo <dyoo at cs.wpi.edu>:
> On Thu, Aug 18, 2011 at 11:45 AM, Shogo Yamazaki <moquo2.718 at gmail.com> wrote:
>> Hi,
>> I have a question about using get/post-pure-port.
>> I'm using Racket v5.1.2.3 and FreeBSD 8.2.
>> It seems tcp-port is still opened after I used get-pure-port.
>> How can I close this? The code is below.
> [code omitted]
> Hmm...  Do you see the same issue if you use a Racket custodian to
> clean up the resources?
> The Systems tutorial talks about custodians a bit:
>    http://docs.racket-lang.org/more/index.html#(part._.Terminating_.Connections)
> Your code would't have to change too much: it'd look something like:
>    (define cust (make-custodian))
>    (parameterize ([current-custodian cust])
>        ;; .. your code, which opens ports and does other stuff
>        (custodian-shutdown-all cust))
> If you open ports in the context of a custodian, that custodian takes
> responsibility for cleaning up resources when custodian-shutdown-all
> gets called.

Posted on the users mailing list.