Know of any cross platform socket library (windows & Linux) in C?

前端 未结 6 1088
自闭症患者
自闭症患者 2021-02-07 12:23

I am looking to do socket communications (listen, accept, connect, recv, send, disconnect) in both linux and windows. My project is in C, so unless someone can think of a way fo

相关标签:
6条回答
  • 2021-02-07 12:59

    I don't know one library that complies both Windows and Linux but I think winsock is similar enough to Linux socket programming.

    In particular it supplies you 'select()' and the other functions mentioned. I guess you will need a very thin #ifdef wrapper to avoid type casting warnings.

    See here the winsock page for select

    0 讨论(0)
  • 2021-02-07 13:00

    check HS Sockets C Source Library for Windows and Linux

    0 讨论(0)
  • 2021-02-07 13:03

    The plibsys library provides all the requested features: cross-platform and portable, lightweight, provides socket IPv4 and IPv6 support as well as many other useful things like multithreading. Works with sockets in non-blocking mode (though you can switch to a blocking one, too). Has quite a good documentation with the test code examples.

    0 讨论(0)
  • 2021-02-07 13:07

    The Boost library includes these features.

    0 讨论(0)
  • 2021-02-07 13:13

    Off-hand, I can think of four libraries:

    • GLib Channels from the GLib framework can abstract socket usage, but you'll need platform-specific code for socket creation.

    • libuv is a platform abstraction layer for node.js and handles, among other things, sockets and async IO.

    • The Apache Portable Runtime also contains network routines.

    • The Netscape Portable Runtime does socket manipulation as well.

    0 讨论(0)
  • 2021-02-07 13:19

    Ptlib provides cross platform C++ code that works well for sockets. www.opalvoip.org

    Copes nicely with threads. Some support for mac and BSD. Under active development and maintainance. MPL Core library in Ekiga - the preferred desktop app that does SIP & H.323

    For windows - it compiles with MSVC. for linux, it compiles with gcc autoconf make etc.

    OK, it is C++, but you can work with that... Have a the source inside ptlib/samples - there are many examples of using ptlib there.

    0 讨论(0)
提交回复
热议问题