Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I made a server with C using socket on a Linux machine and it's working fine but when I tried to run it on windows machine using visual studio, I'm getting an error:
fatal error C1083: Cannot open include file: 'sys/socket.h': No such
file or directory
The ide telling me that this header files are not found.
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
–
–
–
For Windows, you have to use winsock.h
or winsock2.h
and sys/types.h
. Forget about unistd.h
, arpa/inet.h
and netinet.h
. Use a conditional compilation to include the correct header according to the platform.
Also, to use socket under Windows, you application must first call WSAStartup
.
Most of the call are the same between Windows and Linux. But most performance will require to avoid select() (It works) and use Windows functions. See the documentation.
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.