sendfile repro attempt added by teiresias on Tue Jun 14 01:27:19 2022

#!/bin/sh
#|
exec csi -s "$0" "$@"
|#
;; Stupid little attempt to reproduce the sendfile thing.
;; The other end is a server that just discards data:
;; tcpserver 0.0.0.0 3456 redirfd -w 1 /dev/null cat
;; (uses ucspi-tcp and execline packages, you could probably just use discard
;; from xinetd and change the port number).
;; Call client with E.G.,
;; ./repro.scm 13233
(import brev sendfile simple-loops (chicken tcp))

(call-with-output-file
    "/tmp/junk"
  (c write-string
     (make-string (string->number (car (command-line-arguments))) #\a) #f))
(do-forever
 (receive (inp outp)
     (tcp-connect "10.4.20.161" 3456)
   (close-input-port inp)
   (call-with-input-file "/tmp/junk" (fn (sendfile x outp)))
   (close-output-port outp)
   ;; This hangs if we try to connect too fast, gods know why.
   (sleep 1)))