WebSocket Server Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 194
Joined: Thu Aug 03, 2017 12:20 pm

WebSocket Server

Post by Natulux » Tue Oct 08, 2019 12:41 pm

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

User avatar
T-Rex
Moderator
Moderator
Posts: 1182
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Re: WebSocket Server

Post by T-Rex » 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.

Natulux
I live to help wx-kind
I live to help wx-kind
Posts: 194
Joined: Thu Aug 03, 2017 12:20 pm

Re: WebSocket Server

Post by Natulux » Wed Oct 09, 2019 7:16 am

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

Post Reply