问题描述:

I'm planning out a science project, and I'm doing some research about sockets in various languages. Strangely enough, I cannot find whether C has sockets as part of some internal resource, or if the language requires an external library to use sockets. From what I've seen, I'm inclined to think that it is part of an internal resource, but I want to be sure.

Thanks for your time!

网友答案:

Sockets are specified by POSIX but not C by itself. Basically any modern operating system you're likely to encounter except Windows is approximately POSIX-conformant. On Windows, the WINSOCK library provides a very poor substitute for standard POSIX sockets.

网友答案:

No, C is lightweight and doesn't include sockets. But the compiler suite or your OS may have included a socket lib. Most likely you'll need to reference socket.h, netinet/in.h, etc.

网友答案:

#include <sys/socket.h>

网友答案:

I believe the C language itself does not define any input or output, and depends on an external library (std) even for console input/output. See WINSOCK for sockets on windows through C.

网友答案:

Sockets are a part of the libc or of the OS API, so they are not part of the language proper.

相关阅读:
Top