On 17.06.2017 22:22, Didik Setiawan wrote:
> On Sat, Jun 17, 2017 at 01:30:57PM +0300, Evgeny Grin wrote:
>>
>
>> You can combine second and third methods:
>
> I use this combination.
>
>> -----------------------------------------------
>> int port_num;
>>
>> if(0) {}
>> #if MHD_VERSION >= 0x00095501
>> else if (MHD_NO !=
>> MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
>> {
>> const union MHD_DaemonInfo *dinfo;
>> dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
>> if (NULL == dinfo || 0 == dinfo->port)
>> {
>> /* Insert code to handle error. */
>> return -1;
>> }
>> port_num = (int)dinfo->port;
>> }
>> #endif /* MHD_VERSION >= 0x00095501 */
>> else
>> {
>> const union MHD_DaemonInfo *dinfo;
>> MHD_socket sock_fd;
>> dinfo = MHD_get_daemon_info (d, MHD_OPTION_LISTEN_SOCKET);
>
> Don't you mean:
>
> dinfo = MHD_get_daemon_info(d, MHD_DAEMON_INFO_LISTEN_FD);
>
> Because when I tried using MHD version < 0.9.55 the result is not as
> expected.
>
>> if (NULL == dinfo)
>> {
>> /* Insert code to handle error. */
>> return -1;
>> }
>> sock_fd = dinfo->listen_fd;
>> /* Insert code to use port detection on provided socket. */
>> }
>> -----------------------------------------------Right, correct value is MHD_DAEMON_INFO_LISTEN_FD. -- Wishes, Evgeny
signature.asc
Description: OpenPGP digital signature
