Not all struct sockaddr are going to have the sa_family as their first field.
Since there is a named structure member, we can simply use that and let
the compiler sort it out.
This fixes a bug with at least FreeBSD and allows us to remove the
special case for Apple.
As suggested in a PR from @Legend-Master (this change is basically
unrelated to the main point of his PR, so extracted here)
Windows is a confusing and disappointing development environment. They
completely replaced all the definitions in winsock.h with exact
equivalents in winsock2.h (except for a small number of deprecated
functions).
However they didnt make them mutually exclusive - so if you include
both, you get errors. They also automatically include winsock.h from
windows.h, so you must remember to include winsock2.h first. They also
didnt just remove winsock.h and replace it with the new contents.
(Probably in the name of "compatibility", whilst swearing that the new
winsock is the same as the old one - because if you cannot believe two
inconsistent things simultaneously, you shouldnt be a windows
programmer)
All these things are totally nuts. Thanks, windows dev environment,
for not noticing that this is nuts
There is still cleanup work to be done in the headers, but this
concludes the major include-what-you-use refactoring. No functional
change is intended or expected and all tests are passing.
It is now a lot easier to see what is used from each header and work on
possible refactoring in the future.
The include-what-you-use tool is awkward to use with the current state
of the build system - and will always be difficult to use in a
multi-platform safe way. However, I hope to provide a non manual
process for running with the tool in the future.
* Add close window support for Windows
* Support logoff and shudown events as well
Without this change, when you close the terminal/shell window, it won't have the time to clean up which can cause authentication errors if you try to reconnect.
Blocking here infinitely is fine since when our main thread returns, it will shut down anyway
I found Go is doing this when I was searching, and there's a comment explained how it works: https://github.com/golang/go/issues/41884#issuecomment-706695923