What does Windows error code 10009 (WSAEBADF) mean?

 
Previous Next
WSAEINTR WSAEACCES

WSAEBADF

WSAEBADF belongs to the BSD-style error vocabulary retained by Winsock for source compatibility. In portable code its closest semantic ancestor is EBADF: an operation received a descriptor or handle that is not valid for that operation. Microsoft also notes that some values defined in Winsock2.h are not returned by any Winsock function, so the exact producer matters more than the symbolic name alone.

Do not confuse it with a bad socket

Native Winsock calls normally use more specific values such as WSAENOTSOCK when a socket argument is not a socket, or WSA_INVALID_HANDLE for an invalid event object. If WSAEBADF appears in a Windows networking log, identify whether it came from a portability layer, a third-party provider, or code translating errno-style results.

Useful diagnostics

  • Record the exact failing API and retrieve the error immediately with WSAGetLastError.
  • Log handle ownership, close/shutdown history, and cross-thread handoff.
  • Check whether a compatibility wrapper is mapping POSIX descriptors to Winsock handles.

Microsoft: Winsock error codes · Microsoft: errno and WSAGetLastError · POSIX: errno.h


Looking for a different code? Search another status or error code.