Hacker News new | ask | show | jobs
by erkl 4120 days ago
> An unknown address family will return a '0'.

In this particular case, returning 0 doesn't necessarily indicate failure. Binding a socket to port 0 means you're asking the operating system to pick an available port for you, which one might argue is a reasonably safe default for unknown address families.

1 comments

No, there is no 'default' at play here. If you don't know what address family is in use then you should simply abort rather than to let the end user of your product guess that the address family code is the culprit.

Let it crash, as close as possible to the point of origin of a problem is a very good principle.