Category:Ursa: Difference between revisions

mNo edit summary
Line 24:
p.close
</lang>
 
===Single-User Echo Server===
<lang ursa># declare a serverport and a port to attach new connections to
declare serverport sp
declare port p
 
# declare a string to contain lines of input
declare string input
 
# attach the serverport to port 20000
sp.attach 20000
 
# loop indefinitely, getting connections then echoing the data they send
while true
set p (sp.getconn)
out "%msg: connection from " (p.addr) endl console
out "echo server " _version endl endl p
while true
set input (in string p)
out input endl p
if (and (= input "") (not (p.isopen 1000)))
break
end if
end while
p.close
out "%msg: connection closed" endl console
end while</lang>
 
==See Also==
Anonymous user