vi / websocat

Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
MIT License
6.74k stars 261 forks source link

Difference between C-c and C-d signals #74

Open hjpotter92 opened 4 years ago

hjpotter92 commented 4 years ago
┌┤✅├─┤ hjpotter92 ├─┤~├─┤ 🕠 05:31 PM │
└┴─ ⚡[..........] ┴─ ➜ websocat -B 120000000 ws://localhost:12345/
┌┤✅├─┤ hjpotter92 ├─┤~├─┤ 🕠 05:31 PM │
└┴─ ⚡[..........] ┴─ ➜ echo $?
0
┌┤✅├─┤ hjpotter92 ├─┤~├─┤ 🕠 05:32 PM │
└┴─ ⚡[..........] ┴─ ➜ websocat -B 120000000 ws://localhost:12345/
^C%
┌┤✅├─┤ hjpotter92 ├─┤~├─┤ 🕠 05:32 PM │
└┴─ ⚡[..........] ┴─ ➜ echo $?
0

The first time, I did a Ctrl-D keypress, with exit code of 0. The 2nd time, I did a Ctrl-C keypress, with same exit status.

Is there a difference in the state of socket connection? I did not receive a client closed the connection event when I did Ctrl-D.

vi commented 4 years ago

Is there a difference in the state of socket connection? I did not receive a client closed the connection event when I did Ctrl-D.

Ctrl+D sends EOF to terminal and should result in a clean connection close. Websocat should sent a close frame. It is as if information to be sent were read from file and it reached the end of the file.

Ctrl+C simply terminates websocat and socket is closed without special control frame, probably just a FIN TCP packet.

-B 120000000

Note that data processing in websocat is not zero-copy. Expect some slowdown when dealing with gigant messages.