#include #include #include #include #include #include #include uint16_t helper_get_port(int sock) { struct sockaddr_in sin; socklen_t len = sizeof(sin); if (getsockname(sock, (struct sockaddr *)&sin, &len) == -1) { LOG_ERROR("could not get socket name for port: %s\n", strerror(errno)); return 0; } else { return ntohs(sin.sin_port); } }