Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Seems to work. I tested with -b256 and bs=512, the output was identical to what bbe had given me. The manual says -b sends at most such-and-such number of bytes per step. When dd requests 512 bytes, will it always get exactly 256? If for any reason it gets less then the output will go out of sync. Does type=2 guarantee this exactness maybe? Commented May 6, 2020 at 20:35
  • type=2 is a sort of "packet" mode, where each write made towards dd keeps its structure, so a dd read larger than the packet will only get one packet, thus preserving the "structure". If you provide your file as stdin to socat (as in <myfile socat -u ...), then socat will always be able to read the 256 bytes it is asked to. If you use a pipe, as in my example, and the command you are using to fill the pipe is only sending a few bytes at a time, socat might not get the full 256 bytes, and so will send a short packet to dd. So just ensure you provide your file as stdin directly. Commented May 6, 2020 at 21:14
  • I knew socat is a powerful tool but I didn't know this trick. Thanks. +1. Commented May 6, 2020 at 21:21