MVakili Posted August 3, 2023 Share Posted August 3, 2023 I want to display the internet connection and Ping speed similar to what we see in the image at the top of the program to the user. Has anyone had any experience in this field? Quote Link to comment Share on other sites More sharing options...
irigsoft Posted August 3, 2023 Share Posted August 3, 2023 19 minutes ago, MVakili said: I want to display the internet connection and Ping speed similar to what we see in the image at the top of the program to the user. Has anyone had any experience in this field? Hello, for ping with javascript try this with: https://stackoverflow.com/questions/4282151/is-it-possible-to-ping-a-server-from-javascript https://www.geeksforgeeks.org/how-to-ping-a-server-using-javascript/ https://www.tutorialspoint.com/how-to-ping-a-server-using-javascript 1 Quote Link to comment Share on other sites More sharing options...
MVakili Posted August 3, 2023 Author Share Posted August 3, 2023 12 minutes ago, irigsoft said: Hello, for ping with javascript try this with: https://stackoverflow.com/questions/4282151/is-it-possible-to-ping-a-server-from-javascript https://www.geeksforgeeks.org/how-to-ping-a-server-using-javascript/ https://www.tutorialspoint.com/how-to-ping-a-server-using-javascript Thank you for your quick reply But I don't know how to use these codes in UniGui We used to use this method to connect to the Internet function YourFunctionName : boolean; var origin : cardinal; begin result := InternetGetConnectedState(@origin,0); //connections origins by origin value //NO INTERNET CONNECTION = 0; //INTERNET_CONNECTION_MODEM = 1; //INTERNET_CONNECTION_LAN = 2; //INTERNET_CONNECTION_PROXY = 4; //INTERNET_CONNECTION_MODEM_BUSY = 8; end; Quote Link to comment Share on other sites More sharing options...
irigsoft Posted August 3, 2023 Share Posted August 3, 2023 You want to check (show on the client side) what the server status is, right? Quote Link to comment Share on other sites More sharing options...
MVakili Posted August 3, 2023 Author Share Posted August 3, 2023 Yes, that's correct. In fact, the problem consists of several parts: 1. Is there a connection to the server? 2. What is the speed of the connection to the server? 3. What is the speed of the connection between the program and the database? 4. What is the CPU processing power? And similar questions. The goal is actually to be able to check the required aspects on the client side and make the user aware of potential bottlenecks in the operations. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted August 3, 2023 Share Posted August 3, 2023 Hello, 6 minutes ago, MVakili said: 1. Is there a connection to the server? 2. What is the speed of the connection to the server? With your uniGUI server as I understand it!? Quote Link to comment Share on other sites More sharing options...
MVakili Posted August 3, 2023 Author Share Posted August 3, 2023 I think this code is useful for checking ping time to a server Function Ping(const Host: string; Port: Integer):Integer; var Started: Tdatetime; Http: TIdHTTP; begin Started := Now; Http := TIdHTTP.Create(nil); try try Http.Get('http://' + Host + ':' + IntToStr(Port)); Result:=MilliSecondsBetween(TDateTime.Now, Started); except // this is expected end; finally Http.Free; end; end; if IsConnected then Caption:='Connected'+IntToStr(Ping('Server',any port)) Else Caption:='Not Connected' Quote Link to comment Share on other sites More sharing options...
MVakili Posted August 3, 2023 Author Share Posted August 3, 2023 Just now, Sherzod said: Hello, With your uniGUI server as I understand it!? yes thats correct Quote Link to comment Share on other sites More sharing options...
Sherzod Posted August 3, 2023 Share Posted August 3, 2023 1 minute ago, MVakili said: I think this code is useful for checking ping time to a server No, the ping must be from the client side... Quote Link to comment Share on other sites More sharing options...
Sherzod Posted August 3, 2023 Share Posted August 3, 2023 6 minutes ago, MVakili said: 7 minutes ago, Sherzod said: Hello, With your uniGUI server as I understand it!? yes thats correct I think there are many ways to do this. One of them is to simply send a request to the server using ajaxRequest, and determine the time spent on the response from the server. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted August 3, 2023 Share Posted August 3, 2023 2 minutes ago, Sherzod said: I think there are many ways to do this. One of them is to simply send a request to the server using ajaxRequest, and determine the time spent on the response from the server. By sending a few bytes of data. Quote Link to comment Share on other sites More sharing options...
MVakili Posted August 3, 2023 Author Share Posted August 3, 2023 Just now, Sherzod said: No, the ping must be from the client side... In fact, I want to display the client's connection speed to the software (which is hosted on the server). After that, I need to know the speed of the software's connection to the data server (which can be located in different places in our designs). And finally, I need to know the status of the server for processing tasks (whether it is involved in heavy processing or not). Quote Link to comment Share on other sites More sharing options...
Sherzod Posted August 3, 2023 Share Posted August 3, 2023 3 hours ago, MVakili said: And finally, I need to know the status of the server for processing tasks (whether it is involved in heavy processing or not). You may need these properties too. 2 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted August 3, 2023 Share Posted August 3, 2023 http://unigui.com/doc/online_help/api/!!MEMBERTYPE_Properties_uniGUIServer_TUniGUIServerResources.html 1 Quote Link to comment Share on other sites More sharing options...
MVakili Posted August 5, 2023 Author Share Posted August 5, 2023 And finaly for this you can use this function + Unitimer function TDMT.Ping2(const AHost: string): Integer; var ICMP: TIdICMPClient; Started: Tdatetime; begin Result:=-1; Started := Now; ICMP := TIdICMPClient.Create(nil); try ICMP.Host := AHost; ICMP.ReceiveTimeout := 2000; ICMP.Ping(); If (ICMP.ReplyStatus.ReplyStatusType = rsEcho) Then Result:=MilliSecondsBetween(TDateTime.Now, Started); finally ICMP.Free; end; end; in timer procedure TMainForm.UniTimer1Timer(Sender: TObject); Var T : Integer; begin T:=Ping2('1.1.1.1'); if T>=0 then LPing.Caption:=T.ToString+ ' ms' Else LPing.Caption:= ' Error'; end; and for program server as @Sherzod guide me we can use this code Function UniServer(Var RetParams : Tstringlist):Integer; begin With RetParams Do Begin Add('Memory Used:'+UniServerModule.ServerResources.MemoryUsed.ToString+'/'+UniServerModule.ServerResources.PeakMemoryUsed.ToString); Add('Process Memory Used:'+UniServerModule.ServerResources.ProcessMemoryUsed.ToString+'/'+UniServerModule.ServerResources.PeakProcessMemoryUsed.ToString); Add('USER Objects:'+UniServerModule.ServerResources.USERObjects.ToString+'/'+UniServerModule.ServerResources.PeakUSERObjects.ToString); Add('GDI Objects:'+UniServerModule.ServerResources.GDIObjects.ToString+'/'+UniServerModule.ServerResources.PeakGDIObjects.ToString); Add('CPU Usage:'+FloatToStr(UniServerModule.ServerResources.CPUUsage)+'/'+FloatToStr(UniServerModule.ServerResources.PeakCPUUsage)); Add('Handles:'+UniServerModule.ServerResources.Handles.ToString+'/'+UniServerModule.ServerResources.PeakHandles.ToString); End; end; 3 Quote Link to comment Share on other sites More sharing options...
picyka Posted August 5, 2023 Share Posted August 5, 2023 The problem with these server side functions using the timer is that the unigui session doesn't die. Quote Link to comment Share on other sites More sharing options...
MVakili Posted August 6, 2023 Author Share Posted August 6, 2023 7 hours ago, picyka said: The problem with these server side functions using the timer is that the unigui session doesn't die. in timer you can use a variable for counting and Inc(C); if C>5 Then PingTimer.Enabled:=False; and in LPing.OnClick C:=0; PingTimer.Enabled:=True; 1 Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted August 7, 2023 Share Posted August 7, 2023 On 8/5/2023 at 10:31 PM, MVakili said: And finaly for this you can use this function + Unitimer function TDMT.Ping2(const AHost: string): Integer; var ICMP: TIdICMPClient; Started: Tdatetime; begin Result:=-1; Started := Now; ICMP := TIdICMPClient.Create(nil); try ICMP.Host := AHost; ICMP.ReceiveTimeout := 2000; ICMP.Ping(); If (ICMP.ReplyStatus.ReplyStatusType = rsEcho) Then Result:=MilliSecondsBetween(TDateTime.Now, Started); finally ICMP.Free; end; end; in timer procedure TMainForm.UniTimer1Timer(Sender: TObject); Var T : Integer; begin T:=Ping2('1.1.1.1'); if T>=0 then LPing.Caption:=T.ToString+ ' ms' Else LPing.Caption:= ' Error'; end; and for program server as @Sherzod guide me we can use this code Function UniServer(Var RetParams : Tstringlist):Integer; begin With RetParams Do Begin Add('Memory Used:'+UniServerModule.ServerResources.MemoryUsed.ToString+'/'+UniServerModule.ServerResources.PeakMemoryUsed.ToString); Add('Process Memory Used:'+UniServerModule.ServerResources.ProcessMemoryUsed.ToString+'/'+UniServerModule.ServerResources.PeakProcessMemoryUsed.ToString); Add('USER Objects:'+UniServerModule.ServerResources.USERObjects.ToString+'/'+UniServerModule.ServerResources.PeakUSERObjects.ToString); Add('GDI Objects:'+UniServerModule.ServerResources.GDIObjects.ToString+'/'+UniServerModule.ServerResources.PeakGDIObjects.ToString); Add('CPU Usage:'+FloatToStr(UniServerModule.ServerResources.CPUUsage)+'/'+FloatToStr(UniServerModule.ServerResources.PeakCPUUsage)); Add('Handles:'+UniServerModule.ServerResources.Handles.ToString+'/'+UniServerModule.ServerResources.PeakHandles.ToString); End; end; Great ! Thx Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.