Skip to content

Windows: _get_osfhandle asserts in debug mode when given a socket #19722

@dktapps

Description

@dktapps

handles[n_handles] = (HANDLE)(uintptr_t)_get_osfhandle(i);

When calling stream_select() with a stream socket, this will assert in debug binaries, which makes it inconvenient to test some applications.

I'm not sure what could be done to address this. There doesn't seem to be an easy way to ask the CRT if the fd is a file resource.

According to ChatGPT getsockopt() and checking for WSAENOTSOCK might be a better way to check for sockets, but I haven't tried this myself.
Hoping someone with more expertise about the depths of Windows can suggest something.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions