Sign in to follow this  
Followers 0
=sinister=

AutoItOnExit + TCP Question

9 posts in this topic

Ok, I am making a authentication script using TCP, anyways I want to send something to the server when AutoIt exits. When a user is logged on, no one else may log back in, but what if there was a power surge? Would the AutoItOnExit occur? :whistle: I'm a bit worried, and your help is highly appreciated, thanks.

Share this post


Link to post
Share on other sites



interesting question, you should also wonder what would happen if the computer were to hang / un-expectedly reboot.

perhaps a timeout on the login sessions server side? say.. kick out a user if logged in and in-active for more than XX minutes.

else, allow the user to re-connect to a previous session.

Share this post


Link to post
Share on other sites

Ok, I am making a authentication script using TCP, anyways I want to send something to the server when AutoIt exits. When a user is logged on, no one else may log back in, but what if there was a power surge? Would the AutoItOnExit occur? :whistle: I'm a bit worried, and your help is highly appreciated, thanks.

Is this a twist on logic I hadn't thought of?

Surge Protector

Back Up Battery's

Generator

I mean, if you cut power completely off to something without any back up setup, what do you think happens?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

interesting question, you should also wonder what would happen if the computer were to hang / un-expectedly reboot.

perhaps a timeout on the login sessions server side? say.. kick out a user if logged in and in-active for more than XX minutes.

else, allow the user to re-connect to a previous session.

I have no idea how to make a session.. I guess I could try. Well the user list is held on the servers computer, so I could use TCPCloseSocket() with timerint() or so on the server, and make a function (for the client) so if the socket is closed, it goes back to the login screen... and when another user logs in (If the IP is different) it kicks the other person off... WELL... maybe I DO know how to make a session now =D

And Smoke_N... I guess your right, But I think the method where if the user logs back in and the IP isn't different, they are allowed back in. Hopefully this method will work.. tell me what you think.

Share this post


Link to post
Share on other sites

If you want to see kind of what would happen.

  • Compile the script provided here
  • Run Script
  • If you have a "reset" button, click "reset" on your PC
  • If no "reset": Ctrl + Alt + Delete >> Shut Down >> While holding down the Ctrl button click Restart
Now if you exit with the ESC button it will log you escaped with Hotkey, if you exited by any other means, it will log that you exited by another means.

To me what you are asking, is just like killing the process via Task Manager or proceexp.exe, it doesn't allow your executable to finish doing anything else.

HotKeySet('{ESC}', '_ExitNow')

While 1
    Sleep(1000000)
WEnd

Func _ExitNow()
    Exit -4
EndFunc

Func OnAutoItExit()
    If @exitCode = -4 Then
        FileWrite('TestExit.log', 'Exit By Hotkey: ' & @HOUR & ':' & @MIN & ':' & @SEC & @CRLF)
    Else
        FileWrite('TestExit.log', 'Exit By Other Means: ' & @HOUR & ':' & @MIN & ':' & @SEC & @CRLF)
    EndIf
EndFunc

I think that you should just script on the client to note that the server may be down. Then upon startup, make sure your server is in the startup folders. Have it do a check when signed in on how it was last exited. If it wasn't exited and logged by whatever way you want (can be set as you can set Exit -1 or Exit -2 or whatever), then it should allow those people to re-connect.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Eh, my method helps me with a bunch of other scripts, but thanks for the little test script. But i need a bit more help. Could someone help me with the function to see if the user is connected to a socket? Let's say on the server, they were afk, and the server used TCPCloseSocket(), is there a function I could put in a loop to see if they are connected to a socket?

Share this post


Link to post
Share on other sites

Eh, my method helps me with a bunch of other scripts, but thanks for the little test script. But i need a bit more help. Could someone help me with the function to see if the user is connected to a socket? Let's say on the server, they were afk, and the server used TCPCloseSocket(), is there a function I could put in a loop to see if they are connected to a socket?

You're questions are confusing.

TCPCloseSocket() and you are done period.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Sorry i'll try to explain as best I can ><:

So after the server Closes the socket, I want the client to do a certain thing. How do I tell the client the Socket is Closed and to go do that certain thing?

If TCPCloseSocket() Then
;Whateer
EndIf

Is this it?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Sorry i'll try to explain as best I can ><:

So after the server Closes the socket, I want the client to do a certain thing. How do I tell the client the Socket is Closed and to go do that certain thing?

If TCPCloseSocket() Then
;Whateer
EndIf

Is this it?

Hadn't really thought of it to be honest, I always send data to the Client telling it I'm about to shut it off and to run whatever protocol I had programmed into it personally.

Maybe:

$sData = TCPReceive($nSocket, $nCharLen)
If @error Then ;Server has disconnected
    ;Do whatever
EndIf
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0