sustrik / libdill

Structured concurrency in C
MIT License
1.68k stars 156 forks source link

is there a ws client ? #183

Closed GuacheSuede closed 5 years ago

rokf commented 5 years ago

http://libdill.org/documentation.html

There are quite a few WebSocket functions, including client ones. So yeah, you can create a WebSocket client with libdill.

GuacheSuede commented 5 years ago

Thanks. Would it be through this? http://libdill.org/ws_attach_client.html

GuacheSuede commented 5 years ago

@rokf How would i retrieve the http body in a http server ? there are only command and resource fields

rokf commented 5 years ago

An example where a HTTP and WebSocket server are created can be found at https://github.com/sustrik/libdill/blob/master/examples/webapp.c

Look at the html_worker function in that file, to see how to send a body to a client/browser.

sustrik commented 5 years ago

ws_client_attach does HTTP handshake for you, however you can opt to do it by hand:

WS_NOHTTP flag can be combined with socket type flags. If set, the protocol will skip the initial HTTP handshake. In this case resource and host arguments won't be used and can be set to NULL. Skipping HTTP handshake is useful when you want to do the handshake on your own. For example, if you want to implement custom WebSocket extensions or if you want to write a multi-protocol application where initial HTTP handshake can be followed by different kinds of protocols (e.g. HTML and WebSocket).

(from ws_client_attach man page)

GuacheSuede commented 5 years ago

gotcha, thank you