libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] Created Same Server Port But No Error. Why?


From: Christian Grothoff
Subject: Re: [libmicrohttpd] Created Same Server Port But No Error. Why?
Date: Fri, 29 Aug 2014 23:17:23 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.6.0

Hi!

You may create the listen socket yourself (and if successful pass it to
MHD using the MHD_OPTION_LISTEN_SOCKET). That way, you can ensure that
the "SO_REUSEADDR" option is not set and can check for the respective
error on bind().  That is the suggested process for anyone who doesn't
like the various build-in defaults of MHD's listen/bind logic.

Happy hacking!

Christian

On 08/28/14 12:23, Calvin Kwok wrote:
> Hi ,
> 
> I use the following statement to start the daemon with port 8080.
> 
>  MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION, 8080, NULL, NULL,
> &answer_to_connection,"", MHD_OPTION_END);
> 
> 
> It will successfully start the daemon with 8080.
> 
> But when I use the same code to start the daemon in another process. It
> will also successfully create the 8080 port. But I want it should be
> failed. At least return some ERROR message to me that 8080 has been
> occupied by another daemon process.
> 
> *How could I make MHD_start_daemon stop to start the daemon and return
> NULL when a same port in another process has been started?
> *
> 
> 
> Thanks,
> 
> Yuchang



reply via email to

[Prev in Thread] Current Thread [Next in Thread]