mongoose server 6.0 multithread pool

Skip to first unread message

Alexandre Leblanc

Oct 26, 2015, 12:05:08 PM10/26/15
to mongoose-users
hi !  

i'm currently trying to update a server I made using mongoose v 5.6 to v 6.0. The server is multithreaded using a pool of thread. It work fine with  5.6 but I'm not able to replicate the pool on 6.0

binding more than 1 struct mg_connection *nc = mg_bind(mgMgr, s_http_port, ev_handler)  will fail assert(nc!= nullptr);
compile flag MG_ENABLE_THREADS 
on mac osx 10.11 

any idea ?

Thank you ! 

Sergey Lyubka

Oct 29, 2015, 6:39:45 PM10/29/15
to mongoose-users
Yes, this is because you cannot bind more than one connection to the port.

You can work around this:

1. create first manager, and bind it to the port:
struct mg_connection *c = mg_bind(mgr1, s_http_port, ev_handler);
2. from the listening connection, get the socket:
     sock_t sock = c->sock;
3. Start other managers in the loop, and add listening socket to them by cloning the first one:
     struct mg_connection *c = mg_add_sock(mgrN, dup(sock), ev_handler);

Hope that helps.

You received this message because you are subscribed to the Google Groups "mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

Reply all
Reply to author
0 new messages