Glyph Posted June 2, 2007 Share Posted June 2, 2007 (edited) Do $nTimer = TimerInit() $nDiff = TimerDiff($nTimer)/ 1000 ;if Round($ndiff,2) >= "5" Then ;msgbox(0,"Timer","Greater than or equal to 5. Number is - "&$ndiff) ;Exit ;EndIf $ConnectedSocket = TCPAccept($MainSocket) sleep(6000);its over 5 and still wont register Until $ConnectedSocket <> -1 or Round($ndiff,2) < "5" if i make it < "5" then it will work... why wont it work if i go > "5" ? Edited June 2, 2007 by backstabbed tolle indicium Link to comment Share on other sites More sharing options...
BrettF Posted June 3, 2007 Share Posted June 3, 2007 If i make it < "5" then it will work... why wont it work if i go > "5" ?First off all these are what < and > actually do.... > Tests if the first value is greater than the second. < Tests if the first value is less than the second. So < 5 will make it test if the timer is less than 5, and > 5 will test if the timer is greater than 5. So you want it to test if the timer is greater or equal to 5, correct? Try this: TCPStartup () $MainSocket = TCPListen("127.0.0.1", 1234) $nTimer = TimerInit() Do $nDiff = TimerDiff($nTimer)/ 1000 ;If Round($ndiff,2) >= "5" Then ; msgbox(0,"Timer","Greater than or equal to 5. Number is - "&$ndiff) ; ExitLoop ;EndIf $ConnectedSocket = TCPAccept($MainSocket) sleep(6000);its over 5 and still wont register Until $ConnectedSocket <> -1 or Round($ndiff,2) >= "5" Msgbox(0,"Timer","Greater than or equal to 5. Number is - "&$ndiff) I added the bit at the top to make it work... Hope it helps Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Glyph Posted June 3, 2007 Author Share Posted June 3, 2007 (edited) I already have teh sockets opened in my program im just adding this part to it, i know the tcp is opening, and all im just trying to get it to shutdown once the 5 second elapse has come. Full function: expandcollapse popupfunc _accept() Dim $szIPADDRESS = @IPAddress1 Dim $nPORT = 1337 TCPStartUp() $MainSocket = TCPListen($szIPADDRESS, $nPORT) If $MainSocket = -1 Then Exit EndIf Dim $ConnectedSocket = -1 Do $nTimer = TimerInit() $nDiff = TimerDiff($nTimer)/ 1000 ;If Round($ndiff,2) >= "5" Then ; msgbox(0,"Timer","Greater than or equal to 5. Number is - "&$ndiff) ; ExitLoop ;EndIf $ConnectedSocket = TCPAccept($MainSocket) sleep(6000);its over 5 and still wont register Until $ConnectedSocket <> -1 or Round($ndiff,2) >= "5" Msgbox(0,"Timer","Greater than or equal to 5. Number is - "&$ndiff) ; Get IP of client connecting Dim $szIP_Accepted = SocketToIP($ConnectedSocket) Dim $recv While 1 $recv = TCPRecv( $ConnectedSocket, 2048 ) If @error Then GUICtrlSetData($cont1,"Error... Exiting.") sleep(500) Exit EndIf ; Update the edit control with what we got If $recv ="Packet has arrived." Then GUICtrlSetData($cont1, _ "Server" & " |-| " & $recv & @CRLF & GUICtrlRead($cont1)) GUICtrlSetData($cont1,"the dude got the packet!") GUICtrlSetData($cont1,"Server"&" > "&$recv&@crlf) sleep (1500) Exit WEnd If $ConnectedSocket <> -1 Then TCPCloseSocket( $ConnectedSocket ) TCPShutDown() EndFunc oÝ÷ Ù«¢+Ø)¼($ÀÌØí¹Q¥µÈôQ¥µÉ%¹¥Ð ¤(ÀÌØí¹¥ôQ¥µÉ¥ ÀÌØí¹Q¥µÈ¤¼ÄÀÀÀ(í%I½Õ¹ ÀÌØí¹¥°È¤ÐìôÅÕ½ÐìÔÅÕ½ÐìQ¡¸(ìµÍ½à À°ÅÕ½ÐíQ¥µÈÅÕ½Ðì°ÅÕ½ÐíÉÑÈÑ¡¸½ÈÅհѼԸ9յȥ̴ÅÕ½ÐìµÀìÀÌØí¹¥¤(ìá¥Ñ1½½À(í¹%(ÀÌØí ½¹¹ÑM½ÐôQ AÁÐ ÀÌØí5¥¹M½Ð¤(ͱÀ ØÀÀÀ¤í¥Ñ̽ÙÈÔ¹ÍÑ¥±°Ý½¹ÐÉ¥ÍÑÈ)U¹Ñ¥°ÀÌØí ½¹¹ÑM½Ð±ÐìÐì´Ä½ÈI½Õ¹ ÀÌØí¹¥°È¤ÐìôÅÕ½ÐìÔÅÕ½Ðì)5ͽà À°ÅÕ½ÐíQ¥µÈÅÕ½Ðì°ÅÕ½ÐíÉÑÈÑ¡¸½ÈÅհѼԸ9յȥ̴ÅÕ½ÐìµÀìÀÌØí¹¥¤( no luck. Edited June 3, 2007 by backstabbed tolle indicium Link to comment Share on other sites More sharing options...
Glyph Posted June 3, 2007 Author Share Posted June 3, 2007 Fixed it. i added $nTimer = TimerInit() Do outside of the Do function.... DUH! lol. tolle indicium Link to comment Share on other sites More sharing options...
BrettF Posted June 3, 2007 Share Posted June 3, 2007 Fixed it. i added $nTimer = TimerInit() Do outside of the Do function.... DUH! lol.Glad its fixed Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! 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