RedneckTech Posted September 19, 2012 Share Posted September 19, 2012 (edited) When the script exits by exiting the script via shortcut at bottom left, it wont start again. I understand that there are TCP settings being changed , but how would i go about resetting them everytime the script starts. Tried sending everything that needs to close to a text file and reading that at the start. Got this from here but all im trying to do is receive the MSOffice license key as well as others so that everything is on file when we reload computers. But have since stripped the broadcast/receive from sockets because im not really looking for a chat room.P.S. not looking for someone to do the whole script for me, just a way to do something like the _Exit_() function at the start in case the script was exited improperly. Currently need to restart computer in order to get the script to run again (unless you make a dummy exe and run it like i have added)expandcollapse popup$0 = 0 $00 = 0 $000 = 0 $ip = @IPAddress1 ;Makes the servers IP address... default is your @IPADDRESS1. $port = 1018 ;Makes the port # can be anything between 1 and 60000. ;(the maximum is a guess i don't know how many ports there are butits close). ;and ONLY if the port is not already being used. $max_connections = 500 ;How many clients can be connected FUNCTIONABLY to the server... any more and it will not function correctly on the clients side. TCPStartup () $TCPListen = TCPListen ($ip, $port, $max_connections) If $TCPListen = -1 Then _Exit_ () ;Creates a listening Socket Dim $Socket_Data[$max_connections + 1][3] ;add more to the second array to add data. ;(ex) 2 would have another column for data. ;you could make Usernames or ClientIP's in it... anything you want. ;Socket_data EXAMPLE ;$Socket_Data[0][0] = AMOUNT OF CURRENT CLIENTS ;$Socket_Data[1][0] = client 1 ;$Socket_Data[2][0] = client 2 ;$Socket_Data[n][0] = client n ProgressOn ('Socket Data', 'Reseting Socket Data...') For $0 = 0 To $max_connections $Socket_Data[$0][0] = 0 ;To reset the Socket array. ProgressSet (Round (($0 / $max_connections) * 100),'','Reseting Socket Data...') Sleep (10) Next ProgressOff () While 1 _Accept_Connection () Sleep (100) WEnd Func _Accept_Connection () If $Socket_Data[0][0] = $max_connections Then Return ;Makes sure no more Connections can be made. $Accept = TCPAccept ($TCPListen) ;Accepts incomming connections. If $Accept = -1 Then Return For $0 = 1 To $max_connections If $Socket_Data[$0][0] = 0 Then ;Find the first open socket. $Socket_Data[$0][0] = $Accept ;assigns that socket the incomming connection. Do $Recv = TCPRecv ($Accept, 1000000) If ProcessExists ("LicSrvStop.exe") <> 0 Then _Exit_() EndIf FileOpen(@WorkingDir & "LicenseData.txt", 1) FileWriteLine ( @WorkingDir & "LicenseData.txt", $Recv) Sleep(10) Until $Recv <> "" $Recv = StringSplit ($Recv, '^') $Socket_Data[$0][1] = $Recv[1] $Socket_Data[$0][2] = $Recv[2] ;$Socket_Data[$0][n] = $Recv[n] DEPENDING O WHAT YOU DIMMED THE $SOCKET_DATA AS!!! $Socket_Data[0][0] += 1 ;adds one to the Socket list. $00 = 'New Client' $00 = 0 Return EndIf Next Return EndFunc Func _Exit_ () For $0 = 1 To $max_connections TCPCloseSocket ($Socket_Data[$0][0]) Next TCPCloseSocket ($TCPListen) TCPShutdown () Exit EndFuncEdit: Fixed total attrition of grammar and organization Edited September 19, 2012 by RedneckTech Link to comment Share on other sites More sharing options...
RedneckTech Posted September 19, 2012 Author Share Posted September 19, 2012 P.S. sorry for the pathetic grammar/organization in there... brain fried from this among other things today Link to comment Share on other sites More sharing options...
FireFox Posted September 19, 2012 Share Posted September 19, 2012 Hi, I have not the time to help you, but if you are testing the script from your own computer (serv/client) then replace the ip by "127.0.0.1". Use the help file which is simple to start learning tcp, here you have useless lines etc. Br, FireFox. Link to comment Share on other sites More sharing options...
W4RD14L3R Posted October 5, 2012 Share Posted October 5, 2012 try putting this in the top of your script to make it register a function when it closes. OnAutoItExitRegister( '_Exit_' ) This should run your exit function when the script closes. Firefox is right in regards to using 127.0.0.1 as a testing ip as it wont change and it resembles localhost or "Your Computer" but you are right in using @IPAddress1. instead of having the script exit when it is done with the data, keep it running non stop accepting data and running as a server? If you need more info or help pm me 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