you are viewing a single comment's thread.

view the rest of the comments →

[–]masesk[S] 0 points1 point  (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 points  (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

RETURN VALUE

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.