dexto Posted July 7, 2009 Share Posted July 7, 2009 Correct me if I'm wrong about some limits: -The limit for simultaneous connections (client or server) is 100 (since GUI events can be registered are 0x400+99) -If a client can't connect to a server even with example above maximum attempts is 100 for the same reason every time you try GUI event is created. Link to comment Share on other sites More sharing options...
damian666 Posted July 21, 2009 Share Posted July 21, 2009 Hi Kip, nice little UDF you got here mate i was wondering, would this be fast enough to make it a MMORPG server?would it be do-able?or would it be to slow to take like, 50 connections for example?Damian666 and proud of it!!! Link to comment Share on other sites More sharing options...
colafrysen Posted July 25, 2009 Share Posted July 25, 2009 Hi kip. I wonder is is would be possible to have an function that unregisters an event. The reason for this is to use the "normal" TCP functions for sending files without triggering the recieve event. The reason for not using your functions for file transfer is speed, I don't know exactly why it is slower than TCPRecieve and TCPSend, but if the speed was inproved I would use the UDF Instead. [font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size] Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 25, 2009 Share Posted July 25, 2009 @colafrysenMaybe you should try zatorg's Asynchronous sockets UDF, it's quite similar to this but uses normal TCPSend etc... .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Kip Posted July 27, 2009 Author Share Posted July 27, 2009 Uploaded new a new version which meets all the UDF criterias. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Yeik Posted August 1, 2009 Share Posted August 1, 2009 Uploaded new a new version which meets all the UDF criterias.Thank you for declaring your variables. func get_quote() local $quote switch random(1, 3, 1) case 1 $quote = '"' & "A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, " & _ "design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give " & _ "orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, " & _ "fight efficiently, die gallantly. Specialization is for insects." & '"' & " Robert A. Heinlein" case 2 $quote = '"' & "Within each of us lies the power of our consent to health and sickness, to riches and poverty, to freedom " & _ "and to slavery. It is we who control these, and not another." & '"' & " Richard Bach (Illusions)" case 3 $quote ='"' & "Don't handicap your children by making their lives easy." & '"' & " Robert A. Heinlein" EndSwitch MsgBox(0, "Quote for the moment", $quote & @CRLF) EndFunc get_quote() Link to comment Share on other sites More sharing options...
Beomagi Posted August 6, 2009 Share Posted August 6, 2009 I've been using this for so long, but I'm impressed whenever I see stuff like this. Yeah - I limited myself to automating general stuff and some log parsing - but some of these udfs (like this) are just incredible and so simple to use. Really should have lingered on the forums more. Link to comment Share on other sites More sharing options...
kjcdude Posted September 5, 2009 Share Posted September 5, 2009 Correct me if I'm wrong about some limits:-The limit for simultaneous connections (client or server) is 100 (since GUI events can be registered are 0x400+99)-If a client can't connect to a server even with example above maximum attempts is 100 for the same reason every time you try GUI event is created.I've had around 200 simultaneous connections to my server with no real issue. The only problem is speed of the server. The server must in the while loop or else the client will show that the server does not exist. I modified my clients to retry the server every few seconds if it's not available. Link to comment Share on other sites More sharing options...
PaulBaumann Posted September 7, 2009 Share Posted September 7, 2009 Correct me if I'm wrong about some limits:-The limit for simultaneous connections (client or server) is 100 (since GUI events can be registered are 0x400+99)-If a client can't connect to a server even with example above maximum attempts is 100 for the same reason every time you try GUI event is created.Hi,I can't see a limit of 100 connections. Windows accepts MsgIds in a range from WM_USER(0x400) through 0x7FFF. Link to MSDN. Is there a limit of 100 Msgs depending on AutoIt?Best wishesPaul Link to comment Share on other sites More sharing options...
Kip Posted September 7, 2009 Author Share Posted September 7, 2009 (edited) Only a maximum number of controls in a GUI which is 65532. 0x7FFF - 0x400 = 0x7BFF = 31743 Seems enough to me. Edited September 7, 2009 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
kjcdude Posted September 11, 2009 Share Posted September 11, 2009 (edited) I've ran into a really weird error that i'm able to replicate on multiple occasions. >Running:(3.3.1.1):C:\Program Files\AutoIt3\beta\autoit3.exe "X:\Scripts\Update System\Monitor\Server - Updater.au3" C:\Program Files\AutoIt3\beta\Include\TCP.au3 (386) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If $__TCP_SOCKETS[$i][0] Then If ^ ERROR Running through scite and through compiled versions on two different servers i running this script. The weird thing is on 3 other servers i have setup with this script they haven't failed. Those servers are slower than the two that have failed. Edited September 11, 2009 by kjcdude Link to comment Share on other sites More sharing options...
Kip Posted September 11, 2009 Author Share Posted September 11, 2009 Can show us the code that generates the error? MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
kjcdude Posted September 11, 2009 Share Posted September 11, 2009 It's really old code so it's a bit sloppy. It's compiled with the latest TCP.au3 expandcollapse popup#include <TCP.au3> #include <Array.au3> #include <Date.au3> $inifile = @DesktopDir & "\Active.ini" $inifiledata = @DesktopDir & "\Average.ini" $mc = 25 ;total active clients Global $Secs2, $Mins2, $Hour2 ToolTip("SERVER: Creating server...",@DesktopWidth - 145, 30) $hServer = _TCP_Server_Create(88); A server. Tadaa! _TCP_RegisterEvent($hServer, $TCP_NEWCLIENT, "NewClient"); Whooooo! Now, this function (NewClient) get's called when a new client connects to the server. _TCP_RegisterEvent($hServer, $TCP_DISCONNECT, "Disconnect"); And this,... this will get called when a client disconnects. _TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Received"); Function "Received" will get called when something is received While 1 $activetotal = IniRead($inifile, "Active Connections", "Total Active", "0") $active = IniReadSection($inifile, "Connections") local $clist = _TCP_Server_ClientList() Select Case $activetotal <= $mc if @error or $active = 1 then sleep(75) else for $b = 1 to $active[0][0] $activetotaltmp = IniRead($inifile, "Active Connections", "Total Active", "0") if $active[$b][1] = "Not" and $activetotaltmp <= $mc Then _TCP_Send($active[$b][0], "Activate") IniWrite($inifile, "Connections", $active[$b][0], "Active") IniWrite($inifile, "Active Connections", "Total Active", $activetotaltmp + 1) EndIf Next EndIf EndSelect if @error or $active = 1 Then sleep(75) Else for $a = 1 to $active[0][0] _ArraySearch($clist, $active[$a][0]) if @error Then IniDelete($inifile, "Connections", $active[$a][0]) Else ;~ MsgBox(0, "", $active[$a][0] & " " & $clist[0]) EndIf Next EndIf $tactivea = _ArrayFindAll($active, "Active", 0, 0, 0, 0, 1) $tactiveam = _ArrayMax($tactivea) IniWrite($inifile, "Active Connections", "Total Active", $tactiveam) sleep(65) WEnd Func NewClient($hSocket, $iError); Yo, check this out! It's a $iError parameter! (In case you didn't noticed: It's in every function) _TCP_Send($hSocket, "Established Connection"); Sending: "Bleh!" to the new client. local $clist = _TCP_Server_ClientList() ToolTip("SERVER:" & @CRLF & "Total Clients - " & $clist[0] & @CRLF & "Active Clients - " & $activetotal, @DesktopWidth - 145, 30) IniWrite($inifile, "Connections", $hSocket, "Not") EndFunc Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P local $clist = _TCP_Server_ClientList() ToolTip("SERVER:" & @CRLF & "Total Clients - " & $clist[0] & @CRLF & "Active Clients - " & $activetotal, @DesktopWidth - 145, 30); Placing a tooltip right under the tooltips of the client. ;if client disconnects then iniwrite them off the list IniDelete($inifile, "Connections", $hSocket) EndFunc Func Received($hSocket, $sReceived, $iError); And we also registered this! Our homemade do-it-yourself function gets called when something is received. if $sReceived = "Not Active" Then local $clist = _TCP_Server_ClientList() ToolTip("SERVER:" & @CRLF & "Total Clients - " & $clist[0] & @CRLF & "Active Clients - " & $activetotal, @DesktopWidth - 145, 30) $cactive = $hSocket if StringIsDigit($cactive) = 0 Then $c1 = StringSplit($cactive, "x") $convertedd = Dec($c1[2]) IniWrite($inifile, "Connections", $convertedd, "Not") Else IniWrite($inifile, "Connections", $hSocket, "Not") EndIf Else local $dtclients = IniRead($inifiledata, "Total Clients", "Total Clients", "0")+1 local $upavg = IniRead($inifiledata, "Average MB Sec Up", "Average", "0") local $davg = IniRead($inifiledata, "Average MB Sec Down", "Average", "0") local $tticks = IniRead($inifiledata, "Average Time", "Ticks", "0") local $rcvddata = StringSplit($sReceived, ",") IniWrite($inifiledata, "Average MB Sec Up", "Average", round(((($upavg*($dtclients-1))+$rcvddata[2])/$dtclients), 3)) IniWrite($inifiledata, "Average MB Sec Down", "Average", round(((($davg*($dtclients-1))+$rcvddata[3])/$dtclients), 3)) local $avgticks = round((($tticks*($dtclients-1))+$rcvddata[4])/$dtclients, 3) IniWrite($inifiledata, "Average Time", "Ticks", $avgticks) _TicksToTime($avgticks, $Hour2, $Mins2, $Secs2) local $Timef = StringFormat("%02i:%02i:%02i", $Hour2, $Mins2, $Secs2) IniWrite($inifiledata, "Average Time", "Converted", $Timef) IniWrite($inifiledata, "Total Clients", "Total Clients", $dtclients) ;~ _TCP_Server_Send("Processed") EndIf EndFunc Link to comment Share on other sites More sharing options...
Kip Posted September 12, 2009 Author Share Posted September 12, 2009 I don't get an error running that, but maybe if you give the client source too, so I can actually test it. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
kjcdude Posted September 12, 2009 Share Posted September 12, 2009 I don't get an error running that, but maybe if you give the client source too, so I can actually test it. You shouldn't get an error. The error is reproduce able, but you need to get the amount of clients to around 75 before you see the failure. It looks like the system is just getting overloaded and not responding correctly. Here's the client. It probably won't run correctly for you. expandcollapse popup#include <Date.au3> #include <TCP.au3> #include "\\storageownz\IT Folder\Scripts\Update System\Updates\Automated Installs\au3\Store and PC Defs.au3" #include <String.au3> #include <WindowsConstants.au3> ToolTip("CLIENT: Connecting...",10,10) if $storename = "001" Then global $sip = "10.10.10.6" ElseIf $storename = "002" Then global $sip = "10.10.10.7" ElseIf $storename = "003" Then global $sip = "10.10.10.5" ElseIf $storename = "004" Then global $sip = "10.10.10.5" ElseIf $storename = "005" Then global $sip = "10.10.10.5" EndIf $h1 = @DesktopHeight $w1 = @DesktopWidth $vfpre = "\\Nas01\Volume_1\Update System\" $vfexe = "Version Fixer.exe" $vfscript = $vfpre & $vfexe ;~ $tmpini = @DesktopDir & "\tmpdatafile.ini" ;~ FileDelete($tmpini) #include "\\storageownz\IT Folder\Scripts\Update System\Updates\Automated Installs\au3\Includes\NetStats.au3" $tmptimer = TimerInit() $hClient = _TCP_Client_Create($sip, 88); Create the client. Which will connect to the local ip address on port 88 _TCP_RegisterEvent($hClient, $TCP_RECEIVE, "Received"); Function "Received" will get called when something is received _TCP_RegisterEvent($hClient, $TCP_CONNECT, "Connected"); And func "Connected" will get called when the client is connected. _TCP_RegisterEvent($hClient, $TCP_DISCONNECT, "Disconnected"); And "Disconnected" will get called when the server disconnects us, or when the connection is lost. While 1 $tmptimero = TimerDiff($tmptimer)/1000 ;~ $activeq = IniRead($tmpini, "Version Fixer Started", "Activated", "0") Select Case $tmptimero >= 100; and $activeq = 0 _TCP_Send($fSocket, "Not Active") GUICtrlSetData($al1, "Not Active") $tmptimer = TimerInit() ;~ Exit ;~ MsgBox(0, "", "Sent") ;~ Case IniRead($tmpini, "Client Data", "Processed", "0") = 0 and $activeq = 1 ;~ _TCP_Client_Send($rawdata) EndSelect sleep(75) WEnd Func Connected($hSocket, $iError); We registered this (you see?), When we're connected (or not) this function will be called. ;~ MsgBox(0, "", $hSocket) Global $fSocket = $hSocket If not $iError Then; If there is no error... ToolTip("CLIENT: Connected!",10,10); ... we're connected. Else; ,else... ToolTip("CLIENT: Could not connect. Are you sure the server is running?",10,10); ... we aren't. EndIf EndFunc Func Received($hSocket, $sReceived, $iError); And we also registered this! Our homemade do-it-yourself function gets called when something is received. ToolTip("CLIENT: We received this: "& $sReceived, 10,10); (and we'll display it) ;~ #comments-start if $sReceived = "Activate" Then ;~ IniWrite($tmpini, "Version Fixer Started", "Activated", "1") $begin = TimerInit() $stim = TimerInit() Global $Secs1, $Mins1, $Hour1 ProgressOn("Timer", "Starting", "0%", $w1-306, "0") GUICtrlSetData($al1, "Version Fixer Started") Run($vfscript) sleep(5000) GUICtrlSetData($al1, "Waiting for Verification") while 1 sleep(500) Select Case ProcessExists($vfexe) = 0 Run($vfscript) Case ProcessExists($vfexe) <> 0 GUICtrlSetData($al1, "Version Fixer Running") GUICtrlSetData($al1, "Waiting for VC to Close") ProcessWait("Version Checker.exe") ProcessWaitClose("Version Checker.exe") GUICtrlSetData($al1, "Version Fixer Running") ExitLoop EndSelect WEnd ;if timeout occurs then detect and launch again $totaltimep = 9000 ;in seconds - 9000=2.5 hours - 7200=2 hours - 10800=3 hours - 21600=6 hours - 25200=7 hours While 1 $timerm = TimerDiff($begin) $difm = $timerm/1000 if $difm >= $totaltimep Then RunWait("\\nas01\Volume_1\Scripts\force restart.exe") GUICtrlSetData($al1, "Forced Restart") sleep(100) ProgressOff() ExitLoop EndIf $prcts = Round(($difm/$totaltimep) * 100, 2) _TicksToTime($timerm, $Hour1, $Mins1, $Secs1) $Timef = StringFormat("%02i:%02i:%02i", $Hour1, $Mins1, $Secs1) ProgressSet($prcts, $prcts & "%", "Total Time - " & $Timef) _netstat($UpStr,$DownStr) GUICtrlSetData($Download, _StringAddThousandsSep($DownStr) & " MB") GUICtrlSetData($Upload, _StringAddThousandsSep($UpStr) & " MB") $TodayUp = Round(($UpStr - $Tup)/$difm, 3) $TodayDown = Round(($DownStr - $Tdwn)/$difm, 3) GUICtrlSetData($Up, _StringAddThousandsSep($TodayUp) & " MB") GUICtrlSetData($Down, _StringAddThousandsSep($TodayDown) & " MB") if ProcessExists("Version Checker.exe") Then Global $rawdata = @ComputerName & "," & $TodayUp & "," & $TodayDown & "," & $timerm _TCP_Send($hSocket, $rawdata) GUICtrlSetData($al1, "Version Fixer Completed") sleep(30000) ExitLoop EndIf sleep(500) WEnd ;~ ElseIf $sReceived = "Processed" then ;~ IniWrite($tmpini, "Client Data", "Processed", "1") EndIf ;~ #comments-end EndFunc Func Disconnected($hSocket, $iError); Our disconnect function. Notice that all functions should have an $iError parameter. ToolTip("CLIENT: Connection closed or lost.", 10,10) EndFunc Link to comment Share on other sites More sharing options...
kjcdude Posted September 20, 2009 Share Posted September 20, 2009 *Bump* Link to comment Share on other sites More sharing options...
Kip Posted September 20, 2009 Author Share Posted September 20, 2009 Here's the client. It probably won't run correctly for you.Do you have a client which will run correctly for me and without having to run the script 75 times? MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
kjcdude Posted September 23, 2009 Share Posted September 23, 2009 Below is the code and compiled versions of the server/client. For the client, run it with the ip of the server as the command line parameter. The compiled versions below have been tested and confirmed that it still fails. Server Compiled - http://howies.com/tmp/scripts/Server_-_Updater.exe expandcollapse popup#include <TCP.au3> #include <Array.au3> #include <Date.au3> $inifile = @DesktopDir & "\Active.ini" $inifiledata = @DesktopDir & "\Average.ini" $mc = 25 ;total active clients Global $Secs2, $Mins2, $Hour2 ToolTip("SERVER: Creating server...",@DesktopWidth - 145, 30) $hServer = _TCP_Server_Create(88); A server. Tadaa! _TCP_RegisterEvent($hServer, $TCP_NEWCLIENT, "NewClient"); Whooooo! Now, this function (NewClient) get's called when a new client connects to the server. _TCP_RegisterEvent($hServer, $TCP_DISCONNECT, "Disconnect"); And this,... this will get called when a client disconnects. _TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Received"); Function "Received" will get called when something is received While 1 $activetotal = IniRead($inifile, "Active Connections", "Total Active", "0") $active = IniReadSection($inifile, "Connections") local $clist = _TCP_Server_ClientList() Select Case $activetotal <= $mc if @error or $active = 1 then sleep(75) else for $b = 1 to $active[0][0] $activetotaltmp = IniRead($inifile, "Active Connections", "Total Active", "0") if $active[$b][1] = "Not" and $activetotaltmp <= $mc Then _TCP_Send($active[$b][0], "Activate") IniWrite($inifile, "Connections", $active[$b][0], "Active") IniWrite($inifile, "Active Connections", "Total Active", $activetotaltmp + 1) EndIf Next EndIf EndSelect if @error or $active = 1 Then sleep(75) Else for $a = 1 to $active[0][0] _ArraySearch($clist, $active[$a][0]) if @error Then IniDelete($inifile, "Connections", $active[$a][0]) Else ;~ MsgBox(0, "", $active[$a][0] & " " & $clist[0]) EndIf Next EndIf $tactivea = _ArrayFindAll($active, "Active", 0, 0, 0, 0, 1) $tactiveam = _ArrayMax($tactivea) IniWrite($inifile, "Active Connections", "Total Active", $tactiveam) sleep(65) WEnd Func NewClient($hSocket, $iError); Yo, check this out! It's a $iError parameter! (In case you didn't noticed: It's in every function) _TCP_Send($hSocket, "Established Connection"); Sending: "Bleh!" to the new client. local $clist = _TCP_Server_ClientList() ToolTip("SERVER:" & @CRLF & "Total Clients - " & $clist[0] & @CRLF & "Active Clients - " & $activetotal, @DesktopWidth - 145, 30) IniWrite($inifile, "Connections", $hSocket, "Not") EndFunc Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P local $clist = _TCP_Server_ClientList() ToolTip("SERVER:" & @CRLF & "Total Clients - " & $clist[0] & @CRLF & "Active Clients - " & $activetotal, @DesktopWidth - 145, 30); Placing a tooltip right under the tooltips of the client. ;if client disconnects then iniwrite them off the list IniDelete($inifile, "Connections", $hSocket) EndFunc Func Received($hSocket, $sReceived, $iError); And we also registered this! Our homemade do-it-yourself function gets called when something is received. if $sReceived = "Not Active" Then local $clist = _TCP_Server_ClientList() ToolTip("SERVER:" & @CRLF & "Total Clients - " & $clist[0] & @CRLF & "Active Clients - " & $activetotal, @DesktopWidth - 145, 30) $cactive = $hSocket if StringIsDigit($cactive) = 0 Then $c1 = StringSplit($cactive, "x") $convertedd = Dec($c1[2]) IniWrite($inifile, "Connections", $convertedd, "Not") Else IniWrite($inifile, "Connections", $hSocket, "Not") EndIf Else local $dtclients = IniRead($inifiledata, "Total Clients", "Total Clients", "0")+1 local $upavg = IniRead($inifiledata, "Average MB Sec Up", "Average", "0") local $davg = IniRead($inifiledata, "Average MB Sec Down", "Average", "0") local $tticks = IniRead($inifiledata, "Average Time", "Ticks", "0") local $rcvddata = StringSplit($sReceived, ",") IniWrite($inifiledata, "Average MB Sec Up", "Average", round(((($upavg*($dtclients-1))+$rcvddata[2])/$dtclients), 3)) IniWrite($inifiledata, "Average MB Sec Down", "Average", round(((($davg*($dtclients-1))+$rcvddata[3])/$dtclients), 3)) local $avgticks = round((($tticks*($dtclients-1))+$rcvddata[4])/$dtclients, 3) IniWrite($inifiledata, "Average Time", "Ticks", $avgticks) _TicksToTime($avgticks, $Hour2, $Mins2, $Secs2) local $Timef = StringFormat("%02i:%02i:%02i", $Hour2, $Mins2, $Secs2) IniWrite($inifiledata, "Average Time", "Converted", $Timef) IniWrite($inifiledata, "Total Clients", "Total Clients", $dtclients) ;~ _TCP_Server_Send("Processed") EndIf EndFunc Client Compiled - http://howies.com/tmp/scripts/Client_-_Updater.exe expandcollapse popup#include <Date.au3> #include <TCP.au3> ;~ #include "\\storageownz\IT Folder\Scripts\Update System\Updates\Automated Installs\au3\Store and PC Defs.au3" #include <String.au3> #include <WindowsConstants.au3> ToolTip("CLIENT: Connecting...",10,10) ;~ if $storename = "001" Then ;~ global $sip = "10.10.10.203" ;~ ElseIf $storename = "002" Then ;~ global $sip = "10.10.10.7" ;~ ElseIf $storename = "003" Then ;~ global $sip = "10.10.10.5" ;~ ElseIf $storename = "004" Then ;~ global $sip = "10.10.10.5" ;~ ElseIf $storename = "005" Then ;~ global $sip = "10.10.10.5" ;~ EndIf $sip = $CmdLine[1] $h1 = @DesktopHeight $w1 = @DesktopWidth $vfpre = "\\Nas01\Volume_1\Update System\" $vfexe = "Version Fixer.exe" $vfscript = $vfpre & $vfexe ;~ $tmpini = @DesktopDir & "\tmpdatafile.ini" ;~ FileDelete($tmpini) #include "\\storageownz\IT Folder\Scripts\Update System\Updates\Automated Installs\au3\Includes\NetStats.au3" $tmptimer = TimerInit() $hClient = _TCP_Client_Create($sip, 88); Create the client. Which will connect to the local ip address on port 88 _TCP_RegisterEvent($hClient, $TCP_RECEIVE, "Received"); Function "Received" will get called when something is received _TCP_RegisterEvent($hClient, $TCP_CONNECT, "Connected"); And func "Connected" will get called when the client is connected. _TCP_RegisterEvent($hClient, $TCP_DISCONNECT, "Disconnected"); And "Disconnected" will get called when the server disconnects us, or when the connection is lost. While 1 $tmptimero = TimerDiff($tmptimer)/1000 ;~ $activeq = IniRead($tmpini, "Version Fixer Started", "Activated", "0") Select Case $tmptimero >= 100; and $activeq = 0 _TCP_Send($fSocket, "Not Active") GUICtrlSetData($al1, "Not Active") $tmptimer = TimerInit() Exit ;~ MsgBox(0, "", "Sent") ;~ Case IniRead($tmpini, "Client Data", "Processed", "0") = 0 and $activeq = 1 ;~ _TCP_Client_Send($rawdata) EndSelect sleep(75) WEnd Func Connected($hSocket, $iError); We registered this (you see?), When we're connected (or not) this function will be called. ;~ MsgBox(0, "", $hSocket) Global $fSocket = $hSocket If not $iError Then; If there is no error... ToolTip("CLIENT: Connected!",10,10); ... we're connected. Else; ,else... ToolTip("CLIENT: Could not connect. Are you sure the server is running?",10,10); ... we aren't. EndIf EndFunc Func Received($hSocket, $sReceived, $iError); And we also registered this! Our homemade do-it-yourself function gets called when something is received. ToolTip("CLIENT: We received this: "& $sReceived, 10,10); (and we'll display it) #comments-start if $sReceived = "Activate" Then ;~ IniWrite($tmpini, "Version Fixer Started", "Activated", "1") $begin = TimerInit() $stim = TimerInit() Global $Secs1, $Mins1, $Hour1 ProgressOn("Timer", "Starting", "0%", $w1-306, "0") GUICtrlSetData($al1, "Version Fixer Started") Run($vfscript) sleep(5000) GUICtrlSetData($al1, "Waiting for Verification") while 1 sleep(500) Select Case ProcessExists($vfexe) = 0 Run($vfscript) Case ProcessExists($vfexe) <> 0 GUICtrlSetData($al1, "Version Fixer Running") GUICtrlSetData($al1, "Waiting for VC to Close") ProcessWait("Version Checker.exe") ProcessWaitClose("Version Checker.exe") GUICtrlSetData($al1, "Version Fixer Running") ExitLoop EndSelect WEnd ;if timeout occurs then detect and launch again $totaltimep = 9000 ;in seconds - 9000=2.5 hours - 7200=2 hours - 10800=3 hours - 21600=6 hours - 25200=7 hours While 1 $timerm = TimerDiff($begin) $difm = $timerm/1000 if $difm >= $totaltimep Then RunWait("\\nas01\Volume_1\Scripts\force restart.exe") GUICtrlSetData($al1, "Forced Restart") sleep(100) ProgressOff() ExitLoop EndIf $prcts = Round(($difm/$totaltimep) * 100, 2) _TicksToTime($timerm, $Hour1, $Mins1, $Secs1) $Timef = StringFormat("%02i:%02i:%02i", $Hour1, $Mins1, $Secs1) ProgressSet($prcts, $prcts & "%", "Total Time - " & $Timef) _netstat($UpStr,$DownStr) GUICtrlSetData($Download, _StringAddThousandsSep($DownStr) & " MB") GUICtrlSetData($Upload, _StringAddThousandsSep($UpStr) & " MB") $TodayUp = Round(($UpStr - $Tup)/$difm, 3) $TodayDown = Round(($DownStr - $Tdwn)/$difm, 3) GUICtrlSetData($Up, _StringAddThousandsSep($TodayUp) & " MB") GUICtrlSetData($Down, _StringAddThousandsSep($TodayDown) & " MB") if ProcessExists("Version Checker.exe") Then Global $rawdata = @ComputerName & "," & $TodayUp & "," & $TodayDown & "," & $timerm _TCP_Send($hSocket, $rawdata) GUICtrlSetData($al1, "Version Fixer Completed") sleep(30000) ExitLoop EndIf sleep(500) WEnd ;~ ElseIf $sReceived = "Processed" then ;~ IniWrite($tmpini, "Client Data", "Processed", "1") EndIf #comments-end EndFunc Func Disconnected($hSocket, $iError); Our disconnect function. Notice that all functions should have an $iError parameter. ToolTip("CLIENT: Connection closed or lost.", 10,10) EndFunc Link to comment Share on other sites More sharing options...
Kip Posted September 23, 2009 Author Share Posted September 23, 2009 (edited) After deleting the #include <Store and PC Defs.au3> line from the client, and running it with the latest Stable release (Not Beta), everything works fine. Tested with your compiled Server.exe I have had your excact same problem too once. I always put my pc on hybernate mode instead of shutting it down. After a complete reboot everything worked fine again. Edited September 23, 2009 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
kjcdude Posted September 26, 2009 Share Posted September 26, 2009 After deleting the #include <Store and PC Defs.au3> line from the client, and running it with the latest Stable release (Not Beta), everything works fine.Tested with your compiled Server.exeI have had your excact same problem too once. I always put my pc on hybernate mode instead of shutting it down. After a complete reboot everything worked fine again.I'll try running both with the latest stable instead of the beta. 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