4 ms·
WebSockets in curl
- jraph 4y agoI wanted to add WebSocket support in a node.js backend for a game I develop. This project has zero dependency outside node.js itself and I was reluctant to add any dependency for this, so I implemented WebSockets myself, with the help of a few example code and documentation from MDN. It does not handle the edge cases (that I don't need), but it's quite straightforward and I'm far from having Daniel's expertise in this kind of stuff. I trust him to implement WebSockets correctly, it's way easier than most things he probably had to handle in curl. It's good he went for a solution that does not bloat curl. Good to see this feature in Curl too. libcurl is very nice, things are designed in a straightforward way and it's flexible, it's a library done with taste, and the curl program is also very helpful and being able to debug websocket related stuff with it might be very handy. About: > [libwebsockets] seems (too) tightly integrated with event libraries I too often was slowed down by this kind of stuff when wanting to use anything on top of glib, like dbus for instance. These things want your program to be written in a certain way, rather than your program being able to call the library as it sees fit. In particular, you need to bent to the glib's event loop, and good luck if your program does not quite work like this. There are ways, but there are not very well documented.
- jpitz 4y ago> I too often was slowed down by this kind of stuff when wanting to use anything on top of glib, like dbus for instance. These things want your program to be written in a certain way, rather than your program being able to call the library as it sees fit. In particular, you need to bent to the glib's event loop, and good luck if your program does not quite work like this. There are ways, but there are not very well documented. To me, that's where it crosses the line from library to framework.
- matt-attack 4y agoWill this get exposed in the command line tool at some point? Not sure how that would work exactly.
- Ajedi32 4y agoSee the section under the header "Command line tool websockets"
- synotna 4y agoYour question is answered on the page
- throwaway2016a 4y agoUpvoting you because you're being downvoted and I skimmed the page and somehow missed it at first too. The answer is: > The plan is to make curl do websockets similar to telnet/nc. That part of the work has not been started. Edit: Come on man, whoever downvoted me too. It's easy to miss if you skim. I included the answer in my reply. And I tried to save the poster some karma because I thought they were being downvoted more than they deserved. Some people just can't be happy.
- moralestapia 4y ago>The plan is to make curl do websockets similar to telnet/nc. I've been looking at something like this for ages. Thanks, Daniel!
- joemccall86 4y agoI've used https://github.com/vi/websocat https://github.com/vi/websocat in the past and had very good luck with it.
- domh 4y agoSimilar to this, I recently used https://github.com/websockets/wscat https://github.com/websockets/wscat to great success.
- moralestapia 4y agoThank you both, will check them out!