2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 02:52:07 +00:00

Error if bind to privileged port fails

This commit is contained in:
Jarrod Johnson 2021-04-28 08:37:23 -04:00
parent d3fa08d78b
commit 917a51a406

View File

@ -82,9 +82,15 @@ int main(int argc, char* argv[]) {
if (sock < 0) continue;
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &(int){1}, sizeof(int));
if (curr->ai_family == AF_INET) {
bind(sock, (struct sockaddr*)&net4bind, sizeof(struct sockaddr_in));
if (bind(sock, (struct sockaddr*)&net4bind, sizeof(struct sockaddr_in)) < 0) {
fprintf(stderr, "Unable to bind port 302\n");
exit(1);
}
} else if (curr->ai_family == AF_INET6) {
bind(sock, (struct sockaddr*)&net6bind, sizeof(struct sockaddr_in6));
if (bind(sock, (struct sockaddr*)&net6bind, sizeof(struct sockaddr_in6)) < 0) {
fprintf(stderr, "Unable to bind port 302\n");
exit(1);
}
} else {
continue;
}