commit 94e7a07828a3c4d2b5f782c1cafc35169d9bc29f
parent da9f4fd6f2f37346d1cae368ec7683506df2287a
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Thu, 15 Jun 2017 10:42:22 +0300
MHD_get_daemon_info(): return bind port number by MHD_DAEMON_INFO_BIND_PORT
Diffstat:
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
@@ -126,7 +126,7 @@ typedef intptr_t ssize_t;
* Current version of the library.
* 0x01093001 = 1.9.30-1.
*/
-#define MHD_VERSION 0x00095500
+#define MHD_VERSION 0x00095501
/**
* MHD-internal return code for "YES".
@@ -1845,7 +1845,15 @@ enum MHD_DaemonInfoType
* Note: flags may differ from original 'flags' specified for
* daemon, especially if #MHD_USE_AUTO was set.
*/
- MHD_DAEMON_INFO_FLAGS
+ MHD_DAEMON_INFO_FLAGS,
+
+ /**
+ * Request the port number of daemon's listen socket.
+ * No extra arguments should be passed.
+ * Note: if port '0' was specified for #MHD_start_daemon(), returned
+ * value will be real port number.
+ */
+ MHD_DAEMON_INFO_BIND_PORT
};
@@ -3248,6 +3256,11 @@ union MHD_DaemonInfo
MHD_socket listen_fd;
/**
+ * Bind port number, returned for #MHD_DAEMON_INFO_BIND_PORT.
+ */
+ uint16_t port;
+
+ /**
* epoll FD, returned for #MHD_DAEMON_INFO_EPOLL_FD.
*/
int epoll_fd;
@@ -3437,6 +3450,7 @@ enum MHD_FEATURE
/**
* Get whether MHD support automatic detection of bind port number.
+ * @sa #MHD_DAEMON_INFO_BIND_PORT
*/
MHD_FEATURE_AUTODETECT_BIND_PORT = 19
};
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
@@ -6319,6 +6319,8 @@ MHD_get_daemon_info (struct MHD_Daemon *daemon,
return (const union MHD_DaemonInfo *) &daemon->connections;
case MHD_DAEMON_INFO_FLAGS:
return (const union MHD_DaemonInfo *) &daemon->options;
+ case MHD_DAEMON_INFO_BIND_PORT:
+ return (const union MHD_DaemonInfo *) &daemon->port;
default:
return NULL;
};