# This program demonstrates a type of virus. It connects to the runprog 
# process on port 4030 and copies its own code over using the $prog array.
# The new program thus created goes and does exactly the same thing and so on.

proc main
var line fd pln s v

set fd [connect "localhost" 4030]
out fd
in fd
while 1
	set pln 1
	foreach s v in $prog
		if pln!=[rhead v]; printnl; endif
		print [rtail v] " "
		set pln [rhead v]
	nexteach
	printnl
	printnl "."

	# Get OK/ERROR message from runprog just so it doesn't fill
	# up the socket input buffer.
	input line 
wend
endproc
