# =======================
# server script -- tclsh:
# =======================

proc handle {s} {
	global x
	set l [gets $s]
	if {[eof $s]} {
		close $s
		set x done
	}
}

proc accept {nid adr port} {
	fileevent $nid readable [list handle $nid]
	fconfigure $nid -buffering line
}

set s [socket -server accept 6006]
puts "server ready"
vwait x	;# wait for end of transmission
puts "server exits"
exit