lala Posted December 10, 2007 Share Posted December 10, 2007 Hi I am a newbie in AutoIt, Currently i am using a TCP/IP to control a PC. E.g When a computer receive specific Command from TCP/IP, the Auto-IT will take over the window and perform some operation. $sock = TCPAccept($listen) While ($sock > -1) $sData = TCPRecv($iSocket, $iBytes) ; Perform some operation with sData Wend 1. While AutoIt is in the middle of operation such as controling the deskstop and I want to terminate the operation through TCP/IP communication. 2. I want to terminate the AutoIt operation if the TCP communication is broken The only idea that come through my mind was using pooling, but not sure is this the correct way to do thing. $TimeOut = 1 ; Pool the socket for every one second while (1) ;WindowName will prompt when the process completed if (WinWait($WindowName,"",$TimeOut) == 0) Then if ($sock > -1) then exit EndIf WEnd Thanks lala Link to comment Share on other sites More sharing options...
themax90 Posted December 10, 2007 Share Posted December 10, 2007 (edited) Global $NoTCP = 1 HotKeySet("{F1}", "FreezeTCP") ...farther in the script... If $NoTCP = -1 Then TCPRecv($Socket, $Length) If @Error And $NoTCP = 1 Then $LostConnection Func FreezeTCP() $NoTCP *= -1 EndFuncProof of concept. View my TCP Thread.Basically If $NoTCP = 1 Then TCPRecv will be operated. Else It Won't. If TCPRecv returns that you had a failed socket, and $NoTCP = 1, then it will terminate the connection. FreezeTCP basically just flips $NoTCP between -1 and 1. Pressing F1 would freeze communication - but not continue to listen to the stack.So...some pseudo explaination. Sorry - I'm not good at explaining TCP. I've just spent a long time using it.~SmithEdit : nfwu made a priority queue to handle the packet pool/stream - whatever you'd like to call it. Below is a link to my Optimized TCP Generic Update 1. It contains the Queue.http://www.autoitscript.com/forum/index.ph...c=29882&hl= Edited December 10, 2007 by AutoIt Smith 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