# How to flush-output through make-output-port?

**URL:** <https://racket.discourse.group/t/how-to-flush-output-through-make-output-port/2280>\
**Category:** Questions & Answers\
**Created:** [September 3, 2023, 10:14am UTC](https://racket.discourse.group/t/how-to-flush-output-through-make-output-port/2280 "2023-09-03T10:14:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kalimehtar](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/kalimehtar/32/394_2.png) [@Kalimehtar](https://racket.discourse.group/u/Kalimehtar)\
**Post date:** [September 3, 2023, 10:14am UTC](https://racket.discourse.group/t/how-to-flush-output-through-make-output-port/2280/1 "2023-09-03T10:14:04Z")

</div>

I have made a wrapper around some port via

```scheme
(define my-port (make-output-port
     'my-port
     ; This port is ready when the original is ready:
     inner-port
     ; Writing procedure:
     (lambda (s start end non-block? breakable?)
        ...) ...))

```

But if I call `(flush-output my-port)` it doesn't flush data on `inner-port`. Is it possible to catch `flush-output` call and flush wrapped port?

---

<div class="post-metadata">

**Author:** ![ryanc](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/ryanc/32/71_2.png) [@ryanc](https://racket.discourse.group/u/ryanc)\
**Post date:** [September 3, 2023, 3:16pm UTC](https://racket.discourse.group/t/how-to-flush-output-through-make-output-port/2280/2 "2023-09-03T15:16:48Z")

</div>

A call to `(flush-output my-port)` causes a call to your writing procedure with a zero-length buffer region. See the docs for `make-output-port`, the paragraph starting "If the start and end indices are the same..." You must detect that case and handle it to implement flushing.
