socketstimeoutsocat

How to set infinite timout for socat?


From man socat I found this example:

  socat -u \
         /tmp/readdata,seek-end=0,ignoreeof \
         STDIO

         this is an example for unidirectional data transfer (-u). Socat transfers data from file
         /tmp/readdata  (implicit  address  GOPEN),  starting  at  its current end (seek-end=0
         lets socat start reading at current end of file; use seek=0 or no seek option to first
         read the existing data) in a "tail -f" like mode (ignoreeof). The "file" might also be
         a listening UNIX domain socket (do not use a seek option then).

So I tried that out, but immediately notices that there was some timeout going on, as I'd barely had time to move from one terminal, where I run socat, to antoher where I can Enter some text, so I looked up this option:

  -T<timeout>
         Total  inactivity timeout: when socat is already in the transfer loop and nothing
         has happened for <timeout> [timeval] seconds (no data arrived, no interrupt
         occurred...) then it terminates. Up to version  1.8.0.0  "0"  meant  infinite";
         since version 1.8.0.1 "0" means 0 and values <0 mean infinite.
         Useful with protocols like UDP that cannot transfer EOF.

I could verify that socat -T 10 -u /tmp/readdata,seek-end=0,ignoreeof STDIO drops in 10 seconds, but I don't really understand how to to pass a number <0 to -T to have an infinite timeout. -T -1 doesn't seem to alter the default timeout, for instance.


Solution

  • This appears to be a bug in Socat 1.8.0.1 and 1.8.0.2; as a workaround set option -T to a high number of seconds, e.g. 2147483647 (which is more that 68 years)