Echo server: Difference between revisions

Add Seed7 example
m (removed omit for REXX. -- ~~~~)
(Add Seed7 example)
Line 1,543:
; Parent waits for child to finish spawning grandchild
(waitpid child)))))</lang>
 
=={{header|Seed7}}==
The code below uses the library [http://seed7.sourceforge.net/libraries/listener.htm listener.s7i].
The function [http://seed7.sourceforge.net/libraries/listener.htm#waitForRequest%28inout_listener,inout_file,inout_file%29 waitForRequest] returns
requests from new and existing connections.
 
<lang Seed7>$ include "seed7_05.s7i";
include "socket.s7i";
include "listener.s7i";
 
const proc: main is func
local
var listener: aListener is listener.value;
var file: existingConnection is STD_NULL;
var file: newConnection is STD_NULL;
begin
aListener := openInetListener(12321);
listen(aListener, 10);
while TRUE do
waitForRequest(aListener, existingConnection, newConnection);
if existingConnection <> STD_NULL then
if eof(existingConnection) then
writeln("Close connection " <& numericAddress(address(existingConnection)) <&
" port " <& port(existingConnection));
close(existingConnection);
else
write(existingConnection, gets(existingConnection, 1024));
end if;
end if;
if newConnection <> STD_NULL then
writeln("New connection " <& numericAddress(address(newConnection)) <&
" port " <& port(newConnection));
end if;
end while;
end func;</lang>
 
=={{header|Tcl}}==