~aleteoryx/ntalk

7bb165f0212a9342b7bddc7c2092ac6c76ab85de — Aleteoryx a month ago 6ad285e
network timeout

new clients!
2 files changed, 25 insertions(+), 5 deletions(-)

M README.md
M ntalk.tcl
M README.md => README.md +8 -4
@@ 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

M ntalk.tcl => ntalk.tcl +17 -1
@@ 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} {