mattgodbolt / seasocks

Simple, small, C++ embeddable webserver with WebSockets support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Serve multiple ports?

cspain opened this issue · comments

Hey guys,

It is possible for Seasocks to listen and open multiple connections on more than one port? I am thinking of a scenario where we have, say a data channel on port 1234 and control channel on port 5678.

One way I thought of doing this is creating two server objects (one per channel) and having each do server.serve() on its own thread. The parent of these two threads could send data out using server.execute(connection->send) on each server object?

Is there a better way where I can call listen() and handle simultaneous connections on more than one port?

Thanks for creating a great tool!

-Chris

I haven't looked in detail, but I think the thread-per-listener approach is probably your best option. Hooking into the event loop isn't very easy (ie requires code modification) as we discussed a bit in #47 .