mongoose server 6.0 multithread pool

308 views
Skip to first unread message

Alexandre Leblanc

unread,
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 ! 
Alex

Sergey Lyubka

unread,
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 mongoose-user...@googlegroups.com.
To post to this group, send email to mongoos...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages