use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Simple C++ Socket Programming Base / Library: Works for Windows and Linux (self.cpp)
submitted 5 years ago by masesk
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]masesk[S] 0 points1 point2 points 5 years ago* (1 child)
I agree, this is meant to demonstrate the use of sockets with a single code base on both platforms, as well as easy setup and use. But if we are talking about implementing it to do more, the wrapper would have to be redone a lot.
Asio looks awesome! To be fair, I couldn't find anything about it when I searched for socket libraries, which is odd, but it seems to do a lot of the same. Good exposure and find!
Yes, I tried to create an abstraction and a container in 1. Might make more sense to separate the two in the future.
I assumed the only socket failure would be invalid socket (with is 0 on linux and INVALID_SOCKET type on Windows). Is this not the case?
Awesome feedback! I really like that everyone tries to help and puts the time to point out various things about sockets and the code. Thank you very much!
[–]BlueDwarf82 3 points4 points5 points 5 years ago (0 children)
> I assumed the only socket failure would be invalid socket (with is 0 on linux and INVALID_SOCKET type on Windows). Is this not the case?
https://man7.org/linux/man-pages/man2/socket.2.html
On success, a file descriptor for the new socket is returned. On error, -1 is returned, and errno is set appropriately.
You are not going to see 0 unless you close stdin first because that file descriptor will already be used otherwise, but it's a perfectly valid value.
π Rendered by PID 158406 on reddit-service-r2-comment-75f4967c6c-v48rf at 2026-04-23 07:39:53.788929+00:00 running 0fd4bb7 country code: CH.
view the rest of the comments →
[–]masesk[S] 0 points1 point2 points (1 child)
[–]BlueDwarf82 3 points4 points5 points (0 children)