JohnNash Posted May 26, 2016 Share Posted May 26, 2016 I am connectin a autoit code on my machine with an autoit code on my virtual machine. It works mainly by instructing eachother through TCPSend and receive. All well, all good. Runs like a train. We however notice on every occasion that a certain action that is triggered by such a message slows down in reaction time after an hour or so. We personally suspect is has something to do with the fact that we send a lot of messages both ways and some buffer might get full or something like that? We googled for TCP flush/buffer + autoit but found nothing conclusive ... any idea? Should we clear something? Link to comment Share on other sites More sharing options...
AutoBert Posted May 26, 2016 Share Posted May 26, 2016 Bad implementation of TCP in one or both of your scripts. Link to comment Share on other sites More sharing options...
JohnNash Posted May 26, 2016 Author Share Posted May 26, 2016 Yes I also suspect that. Minimal example (hope I didnt delete too much) expandcollapse popupMINIMAL CLIENT.au3 ;communication====================================================================== Global $MainSocket Local $MaxLength = 512 ;Maximum Length Of Text Local $Port = 8080 ;Port Number Local $Server = "xxx" TCPStartup() ; Start the TCP service. $MainSocket = TCPConnect($Server, $Port) If $MainSocket = -1 Then Exit MsgBox(16, "Error", "Unable to connect.") ;MAINLOOP?********************************************************************************************************************************************************************** While 1 Local $fDiff = TimerDiff($hTimer) ; What is difference between time now and $Data=0 $Data = TCPRecv($MainSocket, $MaxLength) ; MsgBox(16,"MessageDebug",$Data) If $Data = "ByeBye" Then MsgBox($MB_SYSTEMMODAL, "Closing Down Client and Server", "Shutting Down", 1) Terminate() EndIf If CountInstances() < $sAnswer And $fDiff > 15000 Then OpenNewInstance() sleep(500);safety loop EndIf WEnd ;******************************************************************************************************************************************************************************* Func OpenANewInstance() $hTimer = TimerInit() ; Begin the timer and store the handle in a variable. AcutalOpeningOfinstance(); here we open something on Client ;HERE we check whether it is opened (omitted) TCPSend($MainSocket, "Server do your Thing") While 1 $Data = TCPRecv($MainSocket, $MaxLength) sleep(100) If $Data = "Client please Continue" Then ExitLoop EndIf WEnd EndFunc expandcollapse popupMINIMAL SERVER. au3 Global $MainSocket = -1 Global $ConnectedSocket = -1 Local $MaxConnection = 1; Maximum Amount Of Concurrent Connections Local $MaxLength = 512; Maximum Length Of String Local $Port = 8080; Port Number Global $Server = InputBox("Question", "IP", "xxxx", "", _ - 1, -1, 0, 0) TCPStartup() $MainSocket = TCPListen($Server, $Port) If $MainSocket = -1 Then Exit MsgBox(16, "Error", "Unable to intialize socket.") Global $switch = 0 While 1 If $ConnectedSocket = -1 Then $ConnectedSocket = TCPAccept($MainSocket) endif $Data = TCPRecv($ConnectedSocket, $MaxLength) If $Data = "ByeBye" Then Terminate() ;MsgBox(16, "Session Ended", "Connection Terminated.") ;Exit Elseif $Data = "Server do your Thing" Then ;Here We do Stuff and then TCPSend($ConnectedSocket, "Client please Continue") EndIf WEnd Link to comment Share on other sites More sharing options...
JohnNash Posted May 26, 2016 Author Share Posted May 26, 2016 I deleted some stuff, for example $sAnswer is a number of instances of a certain program we want to have opened. Note that the sending and receiving works well initially and the code runs as expected. But like i said, it will slow down after an hour, and becomes slower and slower. Link to comment Share on other sites More sharing options...
AutoBert Posted May 26, 2016 Share Posted May 26, 2016 35 minutes ago, JohnNash said: $sAnswer is a number of instances of a certain program we want to have opened each instance needs resources and so i am not wondering when pc slows down. Link to comment Share on other sites More sharing options...
JohnNash Posted May 26, 2016 Author Share Posted May 26, 2016 Just now, AutoBert said: each instance needs resources and so i am not wondering when pc slows down. Hmm but they are also closed after it served its purpose. So never are there more instances open than 3 for example. Plus, in the beginning everything runs smoothly. I really noticed it is the sending + receiving of the command that gets delayed. But no clue why Link to comment Share on other sites More sharing options...
Dent Posted May 26, 2016 Share Posted May 26, 2016 Have you taken a look at Task Manager? Make sure you click 'Show processes from all users' and have a look and see if there is any high CPU/Memory loads from particular processes. You can then trace these back to particular services for instance is svchost.exe is using up a lot of resource, you can then break this down. It does sound to me like some handle or other isn't being closed and freed up properly after use. Link to comment Share on other sites More sharing options...
JohnNash Posted May 28, 2016 Author Share Posted May 28, 2016 Thanks, yes in the mean time I checked, but saw nothing special. Does anyone see something peculiar about my code? I googled some more and found some articles about bufferbloat, could that be relevant? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now