|is like TCP.
[abcdef] [ghijklmn] [opqrst]
--line) mode is just to get one chunk and call it a
--one-message --lineis to get chunk after chunk until we see the LF character.
--lineboundaries between messages are defined by underlying operating system behaviour which is typically not guranteed (like boundaries between content in packets in TCP).
sleep 1ensures that partial data actually gets seen by websocat (not joined together by operating system before getting to websocat).
--linemode-retain-newlines) are called a message and proceed to the other "address".
\nis forced at the end, internal
\ns are replaced by spaces).
--dump-specdebugging option. It shows the overlay structure. With
--line(or simple mode) you'll see
from the short description:
-l, --line Make each WebSocket message correspond to one line
does this mean that websocat consider every line (\n) a message? right?
so sleep 1 ... wait for \n
in an attempt to test your last message I created a server and tested with, but the following is happening:
a created a server with websocat
websocat ws-l:127.0.0.1:8888 -
then I used websocat as client to connect to this server (using the simple one-argument mode)
printf 'A\nB\nC\n' | websocat ws://127.0.0.1:8888
interactively also doesn't work
what works is the two-arguments mode like this
websocat ws://127.0.0.1:8888 -
using websocat one argument mode, wireshark shows that the server is receiving the messages and responding correctly with [ACK] . the strange thing is that the server seems to buffer the messages when I use the one argument mode, and if I use two argument mode then the server will print all the old messages that he received when using the client as one argument mode.
should I open an issue in github?
--linemode-retain-newlinesonly tells to
--linedon t remove the new lines that you remove secretly, because
--lineis removing every
\nthat it found.
--linehave to remove the new lines? the expected is to send every line as a message, now if the server accepts messages without
\nit s ok , but what if the server don t accept messages without
\nlike in the case of websocat server? it is a puzzle
--linemode-retain-newlines, because when using
--linewe are telling
websocatto cut the message by new lines and considere every line 1 message, so
\nhere now is considered a delimiter and not part of the data (payload), so it s obvious and obligatory to remove
\n, and if i want to preserve
\ns then I have to use
websocatbut in the description of the manual , because it doesn't tell you it will remove
--lineshort description should contain i think this :
\nwill be removed and if you want to preserve them use
--linedoesn't even talk about
--linemode-retain-newlinesshort description which is a child of
--lineis talking about
--line, it should be the inverse i think or both which is better.
this will send my multi-line payload as 1 message and will retain
\n . that is good
$ printf 'A\nB\n' | websocat - ws://echo.websocket.org/ A B
now look please when using
this will send 2 messages, every line is considered a 1 message!, and it will remove the
\n from every message sent.
$ printf 'A\nB\n' | websocat ws://echo.websocket.org/ A B