It wouldn’t help the kernel case here, but I’ve long thought that the socket TCP and UDP APIs were bad in the general use case. Having to build and shuffle around the sockaddr structure is too low level for the majority use case. I think most programmers would prefer something like:
int inet_connect(AF_TYPE, destination, port, options, &error);
Also:
int inet_listen(AF_TYPE, port, options, &error);
So for example:
int sock;
inet_err err = NULL;
sock = inet_connect(SOCK_STREAM, “google.com”, 443, NULL, &err);
if ( sock < 0 )
{
printf(“Failed to connect: %s\n”, err->message);
return -1;
}
Basically one level more abstraction in the API. The old API could stick around for people who are doing something weird, but this would cover most use cases I think. Added bonus: programs using this API are trivial to add support for IPv6, it is just a recompile.