Yes, I know that I have to use ICS in sync mode and depend on events. Even I, like many others am not used to think & code like that though, am trying to manage. Actually, I believe I got it. Thing is I don't know how to implement it in my current function. Below is my code where I need to complete my pre-tests. I will appreciate, If you can advise as to how to manage what I am trying to do. Or, you may tell me it is not possible as an answer and I stop losing rest of my remaining hair. Use another way to do it.
function TDeneme.GetLicense(ClientTime:TDateTime; ClientIP,ClientUUID,LicenseType:string):string; stdcall; var Err:string; begin if MinutesBetween(now, ClientTime) > 10 then begin Result := '***ERROR: ClientTime'; WriteLicenseLog('GetLicense', ClientIP, ClientUUID, LicenseType, Result); Result := StringToTableToXML(Result); Exit; end; if ClientIP = EmptyStr then begin Result := '***ERROR: ClientIP empty'; WriteLicenseLog('GetLicense', ClientIP, ClientUUID, LicenseType, Result); Result := StringToTableToXML(Result); Exit; end; if ClientUUID = EmptyStr then begin Result := '***ERROR: ClientUUID empty'; WriteLicenseLog('GetLicense', ClientIP, ClientUUID, LicenseType, Result); Result := StringToTableToXML(Result); Exit; end; if LicenseType = EmptyStr then begin Result := '***ERROR: LicenseType empty'; WriteLicenseLog('GetLicense', ClientIP, ClientUUID, LicenseType, Result); Result := StringToTableToXML(Result); Exit; end; // Is Client alive? First PING it. if not PingClient(ClientIP, 500, Err) then begin Result := '***ERROR: Ping fail. ClientIP:' + ClientIP + '.'; if Err <> EmptyStr then Result := Result + ' ' + Err; WriteLicenseLog('GetLicense', ClientIP, ClientUUID, LicenseType, Result); Result := StringToTableToXML(Result); Exit; end; // PING OK. DO DIRECT TCP CONNECTION if not TestClientConnection(ClientIP, Err) then begin Result := '***ERROR: Client TCP connection fail.'; if Err <> EmptyStr then Result := Result + ' ' + Err; WriteLicenseLog('GetLicense', ClientIP, ClientUUID, LicenseType, Result); Result := StringToTableToXML(Result); end; // Code will continue from here once above is solved. Result := 'LICENSE WILL BE GRANTED; WriteLicenseLog('GetLicense', ClientIP, ClientUUID, LicenseType, Result); Result := StringToTableToXML(Result); end; -----Original Message----- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Angus Robertson - Magenta Systems Ltd Sent: Sunday, March 13, 2016 7:35 PM To: twsocket@lists.elists.org Subject: Re: [twsocket] Pinging multipe hosts > Pretty confused and stuck at the moment. Give this to my literally > *no knowledge* of using sockets. Below is as far as it gets. > WSocket.Connect; > Sleep(3500); // Assuming that amount of time is enough for a local tcp > connection. which is I'm afraid a perfect example of why you would be better starting off with my TMagIpLog component, even if you only look at the source code and modify it for your purposes, although certainly the client side will do everthing you need. The component is not designed as a high traffic server, I mostly use for one-one connections between applications. The most important thing is ICS is generally used in async mode, you NEVER have wait loops or sleep, there is an event that fires when a connection successeds or fails, and that is what riggers you next step. The exception is multi-threaded applications that do nothing else until the next ICS call. Angus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be