Use threading and sockets in C regardless of platform

I need to write a program that uses streams and sockets. What is the best way to do this for different platforms (Linux, Windows, Mac).

I know about POSIX, but POSIX on Win does not exist.

Are there libraries that handle this platform independently?

+5
source share
6 answers

If you really want C (not C ++), I suggest using standard POSIX threads on platforms other than Windows and using pthreads-win32 on Windows. It supports both 32-bit and 64-bit, both MSVC and MinGW. The current version (2.9.1) was released just a month ago, so the project is actively supported. There is also a fork on github with some fixes in the MSVC2010 project.

If C ++ is also an option, I would choose boost, because where standard C ++ evolves (design std::threadin C ++ 11 is evolution from boost::threadetc.)

boost::asio - , ++ , C. , boost::asio I/O Completion Ports (IOCP) Windows, . boost::asio , , , ( ) .

+5

Qt (++) , - ; 100% C.

+1

boost (++): asio - , -

+1

C- C11 . AFAIK C11, () . POSIX P99 pthread, Linux Mac. Windows , , Dinkumware, API, .

C11 API- .

, BSD , .

+1

All Articles