Simple function that takes a socket type and a port, and returns a new socket of that type, bound to that port on the wildcard address (on either IPv4 or IPv6).
This is the modern way to create a socket that will accept connections from other hosts. You use it like that:
int my_socket = bound_socket(SOCK_DGRAM, 8080);
if (my_socket == -1) {
// Failed to get (or bind) socket
}
Note: if it doesn't compile, you may need to define the
feature flags for getaddrinfo
or change the standard.