Thank you so much, Martin and Fredrik. As you advised, added near the top of socketmodule.c (after #import Python.h): #undef _XOPEN_SOURCE_EXTENDED #define _POSIX_PII_SOCKET #undef HAVE_SOCKADDR_SA_LEN It built cleanly and socket now imports.