I was able to make a websocket client using civetweb.h and libRHTTP.so in windows subsystem for linux with ubuntu but the same could not be done using visual studio.
There is no C++ websocket client support in existing root library. I tried to make my own using civetweb library of TCivetweb class.
This worked fine with root in windows subsystem for linux ubuntu 18.
But with visual studio, it is not working in windows. Also in normal ubuntu unable to build with THttpServer support.
Error in Visula studio—>Error: Function mg_connect_websocket_client(host,port,secure,err_buf,sizeof(err_buf),path,NULL,websocket_client_data_handler,websocket_client_close_handler,pclient_data) is not defined in current scope
Did you try tutorials/http/ws.C example.
It is basic example how websocket can be used with THttpServer.
I just tried on my Windows 10 machine - it is fine.
Hi,
Thanks for the quick reply. The THttpServer works fine but I do not want to use that. I want to use a websocket client. I tried to implement one on my own using civetweb api and its ws_client.c example in github. That worked for my windows subsystem for linux ubuntu. But for Visual Studio build of ROOT the same process is not working. I have seen the libRHTTP.dll that has the function definitions required to run ws_client.c.
I never tried to use civetweb as websocket client. Maybe it shoud be compiled with special compiler options. The only you can do - try to ask civetweb developers for support.
I already did that and exactly there lied the question which I asked. After i #include <civetweb.h> or I do root[0].L civetweb.h, I do not get the function mg_connect_websocket_client loaded in the cint interpreter. But as I had shown you earlier the function is present in the DLL. I am attaching the screenshot of my prompt. The function required is not present.
Probably, I know the problem.
civetweb does not provide dllimport / dllexport specifiers for its functions.
Therefore one cannot use it as is from DLL.
Most easy solution for you - take all civetweb sources and build executable yourself.
In this case dllimport is not required.
Thanks for the prompt reply. I may try and work like that. But I wanted to make a portable program in root that could communicate with our data acquisition server via websocket and display it using root libraries and is extensible by users. Thus i wanted to reduce external dependency and wanted to write the code using only root libraries.
The way you are suggesting is making civetweb an external library. Which has to be compiled for every platform. I did not want to do that. Then my code will become platform dependent.
If root civetweb library worked then i could have asked the users to only install root on their machine and run my code.
Probably, we should ask ROOT Windows expert - Bertrand @bellenot .
As I can see, WINDOWS_EXPORT_ALL_SYMBOLS specified in cmake files when building ROOT libraries. But I am not sure, if it is enough to be able use civetweb functions from libRHTTP.dll.
And in general - we use civetweb to implement HTTP server, but implementation can be changed at any time. Therefore civetweb.h not made public.