[Libwebsockets] Detect multiple server run

Stefano Mora stefano.mora at newdep.com
Wed Nov 21 15:39:10 CET 2018


Hello everyone,
I'd like to know if it is possible to detect multiple run of the same server.
My initial guess was that the context parameter should be null, but it is not.
If I run the server twice I see on the console the following:

[2018/11/21 15:34:36:8536] USER: Visit http://localhost:7681
[2018/11/21 15:34:36:8537] ERR: 11
[2018/11/21 15:34:36:8540] NOTICE: Creating Vhost 'default' port 7681, 2 protocols, IPv6 off
[2018/11/21 15:34:36:8542] ERR: ERROR on binding fd 6 to port 7681 (-1 98)
[2018/11/21 15:34:36:8543] ERR: VH default: iface (null) port 7681 DOESN'T EXIST
[2018/11/21 15:34:36:8545] ERR: 22 2140495960
[2018/11/21 15:34:36:8545] ERR: 33
[2018/11/21 15:34:36:8547] USER: LWS_INIT
[2018/11/21 15:34:36:8548] ERR: ERROR on binding fd 6 to port 7681 (-1 98)
[2018/11/21 15:34:36:8549] USER: !! callback reason: 71
[2018/11/21 15:34:37:8553] ERR: ERROR on binding fd 6 to port 7681 (-1 98)
[2018/11/21 15:34:38:8566] ERR: ERROR on binding fd 6 to port 7681 (-1 98)
[2018/11/21 15:34:39:8578] ERR: ERROR on binding fd 6 to port 7681 (-1 98)
[2018/11/21 15:34:40:8583] ERR: ERROR on binding fd 6 to port 7681 (-1 98)
[2018/11/21 15:34:41:8595] ERR: ERROR on binding fd 6 to port 7681 (-1 98)

My code is:
lwsl_err("11\n");
        engineData.context = lws_create_context(&info);
lwsl_err("22 %d\n", engineData.context);
        if (engineData.context==0) {
                lwsl_err("lws init failed\n");
                return 1;
        }
lwsl_err("33\n");

How can I catch the initial problem and gently exit?

Thanks,
regards
---
Stefano Mora / SW Engineer
stefano.mora at newdep.com<mailto:stefano.mora at newdep.com>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20181121/665d2e56/attachment.html>


More information about the Libwebsockets mailing list