From 0b8b5608dca6dd1d764d14b05e007fe3ed5dd6b1 Mon Sep 17 00:00:00 2001 From: bsergean Date: Thu, 8 Sep 2022 14:58:19 -0700 Subject: [PATCH] Update doc to talk about binding to 0.0.0.0 --- docs/usage.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index 92557273..6a3ddc9f 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -301,7 +301,9 @@ This api was actually changed to take a weak_ptr as the first argumen // Run a server on localhost at a given port. // Bound host name, max connections and listen backlog can also be passed in as parameters. -ix::WebSocketServer server(port); +int port = 8008; +std::string host("127.0.0.1"); // If you need this server to be accessible on a different machine, use "0.0.0.0" +ix::WebSocketServer server(port, host); server.setOnConnectionCallback( [&server](std::weak_ptr webSocket, @@ -384,7 +386,9 @@ The webSocket reference is guaranteed to be always valid ; by design the callbac // Run a server on localhost at a given port. // Bound host name, max connections and listen backlog can also be passed in as parameters. -ix::WebSocketServer server(port); +int port = 8008; +std::string host("127.0.0.1"); // If you need this server to be accessible on a different machine, use "0.0.0.0" +ix::WebSocketServer server(port, host); server.setOnClientMessageCallback([](std::shared_ptr connectionState, ix::WebSocket & webSocket, const ix::WebSocketMessagePtr & msg) { // The ConnectionState object contains information about the connection,