ywebserver: try to use port 8080 if port 80 is not available

This commit is contained in:
Stefan Seyfried
2013-05-28 14:35:11 +02:00
committed by Jacek Jendrzej
parent 4bb8fd218a
commit 860443c4e3

View File

@@ -118,9 +118,17 @@ CWebserver::~CWebserver() {
#define MAX_TIMEOUTS_TO_TEST 100
bool CWebserver::run(void) {
if (!listenSocket.listen(port, HTTPD_MAX_CONNECTIONS)) {
dperror("Socket cannot bind and listen. Abort.\n");
if (port != 80) {
fprintf(stderr, "[yhttpd] Socket cannot bind and listen on port %d Abort.\n", port);
return false;
}
fprintf(stderr, "[yhttpd] cannot bind and listen on port 80, retrying on port 8080.\n");
port = 8080;
if (!listenSocket.listen(port, HTTPD_MAX_CONNECTIONS)) {
fprintf(stderr, "[yhttpd] Socket cannot bind and listen on port %d Abort.\n", port);
return false;
}
}
#ifdef Y_CONFIG_FEATURE_KEEP_ALIVE
// initialize values for select