Glyph Posted January 7, 2008 Share Posted January 7, 2008 $i=0 Do $i=$i+1 sleep(10) until $data = "err" or $i = "200" ; wait for "err" for 2 seconds if $i = "200" Then ; if time has expired then tell us it failed! gUICtrlSetData($window,"User denied: "&$connect[2]&@crlf&GUICtrlRead($window)) $i=0 else ;we got teh packet "err" tell us! GUICtrlSetData($window,$data&" from: "&$connect[2]&@crlf&GUICtrlRead($window)) GUICtrlSetData($window,"User accepted: "&$connect[2]&@crlf&GUICtrlRead($window)) $i=0 EndIf After my program gets a udp packet from somewhere, it will initaite this do until... which is after the case statement. So, basically listen for x data, if you find x data then, it will start this do until. If you then get the packet "err" then it will update in the edit box, if not... then it should tell me it was denied, but wait for the packet for 2 seconds first before giving up! Well, all this does is sleep 2 seconds and give up! (denied message) I'm out of ideas.... help! tolle indicium Link to comment Share on other sites More sharing options...
Glyph Posted January 7, 2008 Author Share Posted January 7, 2008 (edited) Fixed it: $timer = TimerInit() AdlibEnable("Timer", 50) Do $data2 = UDPRecv($socket, 256) until $data2 = "err" or $secs >= "05" if not $data2 = "err" and $secs >= "05" Then ; if time has expired then tell us it failed! AdlibDisable() $secs = "0" gUICtrlSetData($window,"User denied: "&$connect[2]&@crlf&GUICtrlRead($window)) EndIf if $data2 = "err" and $secs < "05" Then AdlibDisable() $secs = "0" ;we got teh packet "err" tell us! GUICtrlSetData($window,$data&" from: "&$connect[2]&@crlf&GUICtrlRead($window)) GUICtrlSetData($window,"User accepted: "&$connect[2]&@crlf&GUICtrlRead($window)) EndIf Edited January 7, 2008 by BackStabbed tolle indicium Link to comment Share on other sites More sharing options...
Pioneer5250 Posted January 7, 2008 Share Posted January 7, 2008 is $data being updated properly before the loop and how do you update $data with the value "err" while in the loop 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