# Panic \`BADF\` on a socket

**URL:** <https://ziggit.dev/t/panic-badf-on-a-socket/12491>\
**Category:** Help\
**Tags:** io\
**Created:** [October 13, 2025, 5:52pm UTC](https://ziggit.dev/t/panic-badf-on-a-socket/12491 "2025-10-13T17:52:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Southporter](https://ziggit.dev/user_avatar/ziggit.dev/southporter/32/2500_2.png) [@Southporter](https://ziggit.dev/u/Southporter)\
**Post date:** [October 13, 2025, 6:22pm UTC](https://ziggit.dev/t/panic-badf-on-a-socket/12491/2 "2025-10-13T18:22:43Z")

</div>

> [@CuckooEXE](#):
>
> ```zig
> var writer = conn.stream.writer(&output).interface;
> var reader = conn.stream.reader(&input);
> var server = std.http.Server.init(reader.interface(), &writer);
> 
> ```

I think you are running into the interface copying problem. See [Zig 0.15.1 reader/writer: Don't make copies of @fieldParentPtr()-based interfaces](https://ziggit.dev/t/zig-0-15-1-reader-writer-dont-make-copies-of-fieldparentptr-based-interfaces/11719) for more conversation.

The short answer is to not copy the reader and writer from the stream.

```zig
var writer = conn.stream.writer(&output);
var reader = conn.stream.reader(&input);
var server = std.http.Server.init(reader.interface(), &writer.interface); 

```

To breakdown your issue, you wer copying the writer interface and then passing a pointer to that. This lost the parent fields required because it is now in a local variable that does not have the appopriate fields. The solution is to not capture the interface, but instead capture the parent field and pass a direct reference to the init function

---

_[View the full topic](https://ziggit.dev/t/panic-badf-on-a-socket/12491)._
