I am trying to develop a console app which listens for information on a network (using synapse) and put's it into a database. I am having difficulty get the app to stay open and listen for traffic. I have tried using the echo demo. I have tried adding 'readln' but I still can not get 'echo' to listen.
What should I do?
Find the following snippets of code:
collex.lpr
==========================
uses main;
begin
TTCPEchoDaemon.create; //readln;
end.
=========================
main.pas
========================
Constructor TTCPEchoDaemon.Create;
begin
sock:=TTCPBlockSocket.create;
FreeOnTerminate:=true;
inherited create(false);
end;
Destructor TTCPEchoDaemon.Destroy;
begin
Sock.free;
end;
procedure TTCPEchoDaemon.Execute;
var
ClientSock:TSocket;
begin
with sock do
begin
CreateSocket;
setLinger(true,10);
bind('0.0.0.0','4515');
listen;
repeat
if terminated then break;
if canread(1000) then
begin
ClientSock:=accept;
if lastError=0 then TTCPEchoThrd.create(ClientSock);
end;
until false;
end;
end;
==============================
Any Ideas
What should I do?
Find the following snippets of code:
collex.lpr
==========================
uses main;
begin
TTCPEchoDaemon.create; //readln;
end.
=========================
main.pas
========================
Constructor TTCPEchoDaemon.Create;
begin
sock:=TTCPBlockSocket.create;
FreeOnTerminate:=true;
inherited create(false);
end;
Destructor TTCPEchoDaemon.Destroy;
begin
Sock.free;
end;
procedure TTCPEchoDaemon.Execute;
var
ClientSock:TSocket;
begin
with sock do
begin
CreateSocket;
setLinger(true,10);
bind('0.0.0.0','4515');
listen;
repeat
if terminated then break;
if canread(1000) then
begin
ClientSock:=accept;
if lastError=0 then TTCPEchoThrd.create(ClientSock);
end;
until false;
end;
end;
==============================
Any Ideas