CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2017
    Location
    Greece
    Posts
    130

    Is there any library that abstracts Winsock and Posix socket implementation?

    So, I know that socket programming depends on OS system calls but from my knowledge about operating systems (as a colleague) I know that when you are dealing with sockets you actually need 4 system calls, read(), write(), bind() and listen(). So Is there any good library that does some abstraction for these system calls and based on the OS you are running the program it initialize these functions with the system calls of that OS?

    I found this but if I'm correct what it basically tells you is that you have to implement both windows sockets and Posix sockets and control which code you compile using pre-processor statements.

    I don't want to do that every time, so I'm wondering if there is a good library out there that is abstracting that for me. I searched a lot of times and I can't find any...
    Also I want it to be c compatible too not only c++.

    Thank you

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Is there any library that abstracts Winsock and Posix socket implementation?

    Quote Originally Posted by babaliaris View Post
    So, I know that socket programming depends on OS system calls but from my knowledge about operating systems (as a colleague) I know that when you are dealing with sockets you actually need 4 system calls, read(), write(), bind() and listen().
    It is only for server socket. And there is also accept()...
    Victor Nijegorodov

  3. #3
    Join Date
    Jan 2019
    Location
    Slough
    Posts
    20

    Re: Is there any library that abstracts Winsock and Posix socket implementation?

    I can also suggest the plibsys library: works on both Windows and UNIX systems (see the full list on the project page) with various compilers. Supports IPv4 and IPv6. It has the tests where you can see the usage examples. The library itself is lightweight and portable.

  4. #4
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Is there any library that abstracts Winsock and Posix socket implementation?

    Note: The following examples have been tested using Code::Blocks and GCC on Windows XP (x86) and Debian Testing (AMD64).
    ???
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured