30 lines
996 B
Plaintext
30 lines
996 B
Plaintext
$ 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;
|