Hest Posted July 5, 2008 Share Posted July 5, 2008 (edited) 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 July 5, 2008 by Hest Software:Model Train Calculator (Screen)Autoit3 beginner! Link to comment Share on other sites More sharing options...
monoceres Posted July 5, 2008 Share Posted July 5, 2008 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 More sharing options...
Hest Posted July 6, 2008 Author Share Posted July 6, 2008 Thx alot, I'll give it a try later today. Hope it works, or I'll be back muttley Software:Model Train Calculator (Screen)Autoit3 beginner! Link to comment Share on other sites More sharing options...
Hest Posted July 6, 2008 Author Share Posted July 6, 2008 Just tested it and it works muttley Thx Now I can continue working on my program Software:Model Train Calculator (Screen)Autoit3 beginner! Link to comment Share on other sites More sharing options...
Hest Posted July 6, 2008 Author Share Posted July 6, 2008 Maybe you could help me a little bit more. Sometimes the server stops responding, do you have any idear how to fix that or what the reason could be? It can be after 10 sec or a couple of minutes. Is it possible to make it responde again somehow? Software:Model Train Calculator (Screen)Autoit3 beginner! Link to comment Share on other sites More sharing options...
TerarinKerowyn Posted July 6, 2008 Share Posted July 6, 2008 I would change the Sleep(10) to a more forgiving number of 250 500 750 1000 to be less fearful of CPU usage Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah 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