set ownerqueue [socket $c(OwnerDaemonHost) $c(OwnerDaemonPort)]
fconfigure $ownerqueue -buffering line -translation lf
+
+ # TCP connections can get into a weird state where the client
+ # thinks the connection is open but the server has no record
+ # of it. To avoid this, have the client speak without waiting
+ # for the server. We tolerate "unknown command" errors so
+ # that it is not necessary to restart the ownerdaemon since
+ # that is very disruptive.
+ #
+ # See A TCP "stuck" connection mystery"
+ # https://www.evanjones.ca/tcp-stuck-connection-mystery.html
+ puts $ownerqueue noop
must-gets $ownerqueue {^OK ms-ownerdaemon\M}
+ must-gets $ownerqueue {^OK noop|^ERROR unknown command}
+
puts $ownerqueue create-task
must-gets $ownerqueue {^OK created-task (\d+) (\w+ [\[\]:.0-9a-f]+)$} \
taskid refinfo