From 7bb165f0212a9342b7bddc7c2092ac6c76ab85de Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Mon, 20 Oct 2025 12:19:02 -0400 Subject: [PATCH] network timeout new clients! --- README.md | 12 ++++++++---- ntalk.tcl | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2e78e5efe3b879343ebc3ec9ecc69976677f3b70..fe40828a2ea2e6840a0ba51189c170485a69c1df 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ [nanochat][src] utils -see also [neauoire's client][100r], [olive's client][olive], [chloe's client][chloe], -[soxfox's client][soxfox], -and probably other things +see also [teapot's client][100r], [olive's client][olive], [chloe's client][chloe], +[soxfox's client][soxfox], [d_m's client][d_m], [tbsp's client][tbsp], +[zireh's client][zireh], [wolfdog's client][wolfdog], and probably other things ## `ntalk.sh`: simple nanotalk server @@ -55,5 +55,9 @@ when it was generated and from what server [src]: https://git.phial.org/d6/nanochat [100r]: https://git.sr.ht/~rabbits/nanotalk [olive]: https://git.sr.ht/~olive/moonchat -[chloe]: https://git.sr.ht/~angelwood/catchat +[chloe]: https://git.sr.ht/~angelwood/picopico [soxfox]: https://codeberg.org/soxfox42/nanocat +[d_m]: https://git.phial.org/d6/electrum +[tbsp]: https://codeberg.org/tbsp/slyther +[zireh]: https://github.com/bctnry/rkt-nanochat +[wolfdog]: https://codeberg.org/lobo/nanite diff --git a/ntalk.tcl b/ntalk.tcl index 4af95563a240c96bd1d5ef1bd9f08f8c0b1e8bbc..2a3bdc5aec2abbea1b62046cd8f0e2684d0bb9ac 100755 --- a/ntalk.tcl +++ b/ntalk.tcl @@ -319,7 +319,7 @@ menu .menu.server.rm -tearoff 0 .menu.nt add command -label "about ntalk" -command { tk_messageBox -title "about ntalk" \ -message "ntalk\nby aleteoryx" \ - -detail "last updated 2025-10-17" \ + -detail "last updated 2025-10-18" \ -icon "info" } .menu.nt add separator @@ -735,6 +735,18 @@ proc neterr {} { restart } +set nettimeout {} +proc heartbeat {} { + global nettimeout + killtimeout + # double-wait, in case we're coming out of suspend + set nettimeout [after 10000 {set nettimeout [after 20000 neterr]}] +} +proc killtimeout {} { + global nettimeout + after cancel $nettimeout +} + set next {} set sendqueue {} @@ -742,6 +754,7 @@ proc incoming {sok} { global next if [catch { while {[gets $sok line] != -1} { + heartbeat; # yay networking! eval $next [list $line] } if {[eof $sok]} { neterr } @@ -755,11 +768,14 @@ proc sendl {line} { puts $sok $line flush $sok }] { neterr } + + heartbeat; # start timeout } proc pumpq {} { global next sendqueue set sendqueue [lassign $sendqueue send recv] set next $recv + killtimeout; # in case $send == {} eval $send } proc sendq {send recv} {