curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: curl with websockets

From: Pierre Brico via curl-users <curl-users_at_lists.haxx.se>
Date: Fri, 17 Jun 2022 15:10:50 +0200

Hi,

Just my 2 cents: is it possible to design it as it will be interactive?
Here is what I imagine:

INPUT=$(mktemp -u)mkfifo -m 600 "$INPUT"
OUTPUT=$(mktemp -u)mkfifo -m 600 "$OUTPUT"

(cat "$INPUT" | curl wss://example.com/ -o "$OUTPUT") &

NCPID=$!
exec 4>"$INPUT"exec 5<"$OUTPUT"
echo "$COMMAND1" >&4read -u 5 -r RESPONSE1;echo "Response: '$RESPONSE1'"

echo "$COMMAND2" >&4read -u 5 -r RESPONSE2;echo "Response: '$RESPONSE2'"


Pierre






On Fri, Jun 17, 2022 at 2:26 PM Stefan Eissing via curl-users <
curl-users_at_lists.haxx.se> wrote:

>
>
> > Am 17.06.2022 um 13:23 schrieb Daniel Stenberg <daniel_at_haxx.se>:
> >
> > On Fri, 17 Jun 2022, Stefan Eissing wrote:
> >
> >> echo "hello little ws" | curl wss://example.com/
> >
> > Yes, but I was also thinking sending a default message and then go into
> the interactive mode. Like this:
> >
> > $ curl -d "hello little ws" wss://example.com/
> > yes
> > you
> > silly
> > ^d
> >
> > With some initial feedback via Twitter my list of ideas now looks like
> this:
> >
> > - Read stdin and send off as messages. Consider newline as end of
> fragment.
> > (default to text? offer option to set binary)
>
> There are --data-* options for that, I guess?
>
> > - Respond to PINGs automatically
> > - Issue PINGs at some default interval (option to switch off/change
> > interval?)
>
> Something like --keepalive-time on the ws layer. Unimaginative
> --ws-keepalive-time
>
> > - Allow `-d` to specify (initial) data to send (should the format allow
> for
> > multiple separate frames?)
> > - Exit after N messages received, where N can be zero.
>
> Or a duration.
> --ws-receive-timeout N: expect non-ping response data at least every N
> fractional seconds
> --ws-receive-duration N: close the websocket after N fractional seconds,
> not matter if data has been received or not
>
> >
> > --
> >
> > / daniel.haxx.se
> > | Commercial curl support up to 24x7 is available!
> > | Private help, bug fixes, support, ports, new features
> > | https://curl.se/support.html
>
> --
> Unsubscribe: https://lists.haxx.se/listinfo/curl-users
> Etiquette: https://curl.se/mail/etiquette.html
>


-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2022-06-17