Page 1 of 1

WebSocket Server

Posted: Tue Oct 08, 2019 12:41 pm
by Natulux
Hey.

I used to use wxSocketBase to host a local server and (maybe) misused it even as HTTP server. Now I want to add a WebSocket server functionality, but I am not sure if the wxSockets are suited for this case. My client will be javascript from a 'webside', which my C++/wxWidgets program will host in an embedded browser. The purpose is communication between web page and server. The page can always fire an http request, but the server does not have this possiblity. That is why I wanted to try websockets.
To my understanding they are basically like http request/response, but the connection, once established, is not closed after the handshake and kept open for further request / response scenario + the server can send requests to the client. This means either event based handling on the server side (wxSocketBase) or a seperate thread.

Do you know about a WebSocket - Server implementation for C++/wxWidgets (msw)? Do you think, I could use wxSocketBase easily to implement a (local) webSocket server? I would like to just enhance my pseudo server (sindce it basically is also http/tcp) but my first concern is, how to seperate WebSocket request from HTTP requests. The scheme would help (http://localhost vs. ws://localhost) but I have not found any way to get the scheme from any incoming wxSocketBase request yet.

Thanks
Natulux

Re: WebSocket Server

Posted: Tue Oct 08, 2019 3:05 pm
by T-Rex
Just use libwebsockets in your application. You should be able to build it on all popular platforms, as a 3rd-party library which will be used for your app.

Re: WebSocket Server

Posted: Wed Oct 09, 2019 7:16 am
by Natulux
T-Rex wrote:
Tue Oct 08, 2019 3:05 pm
Just use libwebsockets in your application. You should be able to build it on all popular platforms, as a 3rd-party library which will be used for your app.
Thank you for the hint!
I'll have a look into it. I hope I can include this in my static build, but on first glance it provides everything I need.

Cheers
Natu