I'm desperate for a bit of help. I am try to create a small app which will send messages to a tcp server.
Problem is the server is not available the main unit should continue, but at the moment it just seems to halt waiting for a connect.
Please have a look at http://pastebin.com/d1662d999 and let me know where I am going wrong
{*********************************************Data Msg Unit**********************************************}unit datamsg;{$mode objfpc}{$H+}interfaceuses Classes, SysUtils, lnet;type { TLTCPMsg } TLTCPMsg = class private FCon: TLTcp; // the connection public constructor Create; destructor Destroy; override; procedure Run(Recvstring : String; Port : word); end;implementationconstructor TLTCPMsg.Create;begin FCon := TLTCP.Create(nil); // create new TCP connection with no parent component FCon.Timeout := 100; // responsive enough, but won't hog cpuend;destructor TLTCPMsg.Destroy;begin FCon.Free; // free the connection inherited Destroy;end;procedure TLTCPMsg.Run(Recvstring : String; Port : word);var s: string; // message-to-send and address Sent, conwait: integer;begin conwait := 0; if FCon.Connect('localhost', Port) then begin // if connect went ok repeat FCon.CallAction; // wait for "OnConnect" sleep(100); until (FCon.Connected) or (conwait = 3); if FCon.Connected then begin // if we connected succesfuly repeat Sent := Fcon.SendMessage(Recvstring); Delete(Recvstring, 1, Sent); FCon.Callaction; // eventize lNet loop until Sent = 0; // try until all data is sent end; // if not FQuit end; // if Connectend;end.{**************************************excerpt of main unit*************************************} uses Classes, SysUtils, ZConnection, ZDataset, lNet , oxounit, inifiles,datamsg;procedure TTCPEchoDaemon1.OnRe(aSocket: TLSocket);var s: string; n: Integer;begin if aSocket.GetMessage(s) > 0 then begin RecvString(s); FCon.IterReset; end;end;function TTCPEchoDaemon1.RecvString(S2: String): AnsiString;var n : integer; Stringtest : String;begin n := 1; while n <= Length(S2) do begin if S2[n] = LF then begin myconverterfunc1:=@CallConv1; myconverterfunc1(Stringtest); stringtest := ''; Delete(S2, n, 1); Continue; end; Stringtest := Stringtest+Copy(S2, n, 1); inc(n); end;end;Function CallConv1 (S1: String): String;varSendMSG:TLTCPMsg;begin oxoparse1.PbxGet(RegExpStr1,S1,SiteID1); //If tcp socket is not available I never get past here sendMSG := TLTCPMsg.Create; sendMSG.Run(S1,4512); sendMSG.Destroy; writeLn(S1);end;