Wrapping libwebsockets C Library with Julia

I’m wrapping libwebsockets in Julia for better integration and performance. Unfortunately, I didn’t find it in JuliaBinaryWrappers. After that i want to introduce simpler analogue for HTTP.jl based on this c lib (previously i tried libcurl, however, there is no websocket support). Do you have any advices? This is my first time wrapping lib myself (before that I used libCurl_jll)

I’m sure that the right thing to do is to use something like Clang.jl to generate the wrapper for you. I don’t know much about it, even though I have drug my eyes over the documentation a few times.

If you are mildly masochistic, you can write Julia analogs of the structures used, and call all of the library functions from Julia using @ccall. I have a semi-large-ish C++ library that I have wrapped that way. I don’t have any experience with libwebsockets, but it looks semi-large. Probably large enough to make fussing around with Clang worthwhile.

Here is my example code (in this Discourse link). Since you are wrapping C, you wouldn’t need to have a C library wrapper layer. I do recommend that you get bindings autogenerated, rather than doing it manually though.

And what about BinaryBuilder? Or is this previous stage before using Clang.jl to generate wrapper?

You may be right - I haven’t successfully used Clang.jl before.

Also, have you seen: GitHub - JuliaWeb/WebSockets.jl: A WebSockets library for Julia?

Both are kind of necessary steps. I prefer doing the binarybuilder one first because it tends to make the following steps a lot easier though nothing stops you from building the wrapper with a local build.