program tserver;
{$M 16536,8192}

uses dvcrt, dvinet, winsock, strings;

var
    arq_respost, arq_form1, arq_form2: text;
    sockListen, sock: integer;
    s: string;
    vet: array [0..2000] of char;
    i, n: integer;

begin
    abreWinSock;

    writeln ('esperando');
    sockListen := escutaConexao (80);
    repeat
         delay (500);
    until chegouRede (sockListen);

    sock := aceitaConexao (sockListen);
    writeln ('conectou');
    fechaConexao (sockListen);

    s := '';
    n := 1;
    repeat
        if chegouRede (sock) then
             begin
                 n := recv (sock, @vet, 2000, 0);
                 for i := 0 to n-1 do
                     write (vet[i]);
             end;
    until n = 0;

    fechaConexao (sock);
    fechaWinSock;

    readln;
    donewincrt;
end.
