Correct way to completely stop a websocketpp::server object

1,375 views
Skip to first unread message

Eric Lloyd

unread,
Jul 18, 2013, 12:04:50 PM7/18/13
to webso...@googlegroups.com
Hi all,

I'm just wondering if there is an easy existing method for cleanly shutting down a websocketpp::server object. In my application, the user is able to turn the server off and on, so I'd like to be able to 'start' and 'stop' the server on demand. I'm looking for a clean way to 'stop' the server.

I know that calling m_server.stop() (where m_server is my server member variable, a websocketpp::server<websocketpp::config::asio> instance) will stop the asio run loop, but even if I call this, there are still open socket connections on my machine. For any existing connected clients, I could probably iterate through a list of them and call m_server.close(conn, ...) to close them, but I don't think that would close the sockets that are listening for incoming connections.

So is there another method I'm missing, or a better way to shut down the server without destroying the object as a whole?

Peter Thorson

unread,
Jul 26, 2013, 12:05:00 PM7/26/13
to Eric Lloyd, webso...@googlegroups.com
Hi Eric,

There isn't a simple method at the moment for instructing a server to stop listening/accepting new connections. This is a feature that I do intend to implement though. It isn't particularly complicated to do so I may be able to get to it this weekend.

Options until that point are the ones you suggested.
- endpoint::stop() will stop listening and forcibly disconnect all connections.
- Keeping a list of connections and calling endpoint::close() will gracefully close them all but won't stop new connections.

Peter

--
You received this message because you are subscribed to the Google Groups "WebSocket++" group.
To unsubscribe from this group and stop receiving emails from it, send an email to websocketpp...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Takatoshi Kondo

unread,
Jan 1, 2015, 1:42:57 AM1/1/15
to webso...@googlegroups.com, erl...@gmail.com
Hi Peter,

I tried calling endpoint::stop(). Then I got some memory leaks report by valgrind.

Here are a valgrind's log, a server program and a client program:
https://gist.github.com/redboltz/a7a9c5abfdeca803dbd5

Is there any good way to stop the leaks?

--
Takatoshi

2013年7月27日土曜日 1時05分00秒 UTC+9 Peter Thorson:
Reply all
Reply to author
Forward
0 new messages