Jump to content

Stop program from closing


Recommended Posts

I found this little code for a server that receives a username and password and sends back an OK. After that the program closes.

How can I make the program continue and start over? I want it to stay in the background and listen for another "login" over and over.

Its the SERVER kode on this page http://www.autoitscript.com/forum/index.ph...mp;#entry530049

; Server (Start first)
TCPStartup()
$listen = TCPListen("127.0.0.1", 2111)
Global $username = "admin", $password = "password"
Global $loggedin = False
Do
    Sleep(10)
    $socket = TCPAccept($listen)
    If $socket <> -1 Then
        Do
            Sleep(100)
            $temp = TCPRecv($socket, 256)
        Until $temp <> ""
        $array = StringSplit($temp, "|")
        If $array[1] == $username And $array[2] == $password Then
            TCPSend($socket, "Connected")
            $loggedin = True
        Else
            TCPSend($socket, "Connection failed")
            TCPCloseSocket($socket)
            $socket = -1
        EndIf
    EndIf
    
Until $socket <> -1
MsgBox(0,"Success","Someone connected ")
Edited by Hest
Software:Model Train Calculator (Screen)Autoit3 beginner!
Link to comment
Share on other sites

Cool my code muttley

Don't have time to test, but try change "Until $socket <> -1" To "Until False". It should work :)

And of course, move the MessageBox to the line under $loggedin=True if you still want the visual confirmation :(

Good Luck!

Broken link? PM me and I'll send you the file!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...