autoitxp Posted May 28, 2007 Share Posted May 28, 2007 Hi here is my code i have problem realated receiving data Properly how i can exitloop after writing file in func _tcprecv() and btn1 button stop responding after on click expandcollapse popup#include <GUIConstants.au3> Dim $ConnectedSocket = -1 Dim $szServerPC = @ComputerName Dim $szIPConvert = TCPNameToIP($szServerPC) Opt("GUICoordMode", 1) GUICreate("File Download Client", 600,500) Dim $edit = GUICtrlCreateEdit("",100,150,300,100) Dim $szIPADDRESS = GUICtrlCreateInput ($szIPConvert, 100, 30, 150, 20) Dim $nPORT = GUICtrlCreateInput ("5110", 100, 60, 150, 20) $filepath = GUICtrlCreateInput (@HomeDrive&"\"&'MyFile.txt', 100, 100, 150, 20) GUICtrlCreateLabel ("Remote Ip:", 30, 32) GUICtrlCreateLabel ("Port:", 30, 60) GUICtrlCreateLabel ("Status:", 30, 150) GUICtrlCreateLabel ("File Path:", 30, 100) $btn1 = GUICtrlCreateButton("Connect", 300, 45, 100) $btn2 = GUICtrlCreateButton("Download", 300, 95, 100) GUISetState() TCPStartUp() Dim $ConnectedSocket = -1 Dim $buffer = "" While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $GUI_EVENT_MINIMIZE Case $msg = $GUI_EVENT_MAXIMIZE Case $msg = $btn1 call ("_TcpConnection") Case $msg = $btn2 call ("_tcprecv") EndSelect WEnd Func _tcprecv() While 1 $buffer = TCPRecv( $ConnectedSocket, 2048) GUICtrlSetData($edit, " > " & $buffer & @CRLF & GUICtrlRead($edit)) $filewrite = FileWrite(GUICtrlRead($filepath),$buffer) Wend EndFunc func _TcpConnection() ConsoleWrite(GUICtrlRead($szIPADDRESS) & @CRLF & GUICtrlRead($nPORT) & @crlf) $ConnectedSocket = TCPConnect(GUICtrlRead($szIPADDRESS), GUICtrlRead($nPORT) ) if $ConnectedSocket = -1 then GUICtrlSetData($edit, " > " & "No Connection Result" & " " & $ConnectedSocket & @CRLF & GUICtrlRead($edit)) Else GUICtrlSetData($edit, " > " & "Connection Successful" & " " & $ConnectedSocket & @CRLF & GUICtrlRead($edit)) EndIf EndFunc Link to comment Share on other sites More sharing options...
acidfear Posted May 28, 2007 Share Posted May 28, 2007 (edited) Func _tcprecv() While 1 $buffer = TCPRecv( $ConnectedSocket, 2048) GUICtrlSetData($edit, " > " & $buffer & @CRLF & GUICtrlRead($edit)) $filewrite = FileWrite(GUICtrlRead($filepath),$buffer) If not @error then exitloop Wend EndFunc is that what you are talking about? I don't understand what you mean by stop responding after button click? Edited May 28, 2007 by acidfear Link to comment Share on other sites More sharing options...
autoitxp Posted May 29, 2007 Author Share Posted May 29, 2007 yaa but now its not receiving all data on click Link to comment Share on other sites More sharing options...
autoitxp Posted May 29, 2007 Author Share Posted May 29, 2007 (edited) Hi this function works fine but when i click on button its not having proper data stream Func _tcprecv() While 1 $buffer = TCPRecv( $ConnectedSocket, 2048) GUICtrlSetData($edit, " > " & $buffer & @CRLF & GUICtrlRead($edit)) $filewrite = FileWrite(GUICtrlRead($filepath),$buffer) If not @error then exitloop Wend EndFunc can we use do until ? like Func _tcprecv() do $buffer = TCPRecv( $ConnectedSocket, 2048) GUICtrlSetData($edit, " > " & $buffer & @CRLF & GUICtrlRead($edit)) $filewrite = FileWrite(GUICtrlRead($filepath),$buffer) Until buffer > "" EndFunc but again its not exiting loop need help Edited May 29, 2007 by autoitxp Link to comment Share on other sites More sharing options...
autoitxp Posted May 30, 2007 Author Share Posted May 30, 2007 how to end loop after successful receving data stream hey this is general support forum and no one is responding. Link to comment Share on other sites More sharing options...
Gif Posted May 30, 2007 Share Posted May 30, 2007 (edited) hey this is general support forum and no one is responding. ... $buffer = TCPRecv( $ConnectedSocket, 2048) If @error Then ExitLoop If $buffer <> "" Then GUICtrlSetData($edit, " > " & $buffer & @CRLF & GUICtrlRead($edit)) $filewrite = FileWrite(GUICtrlRead($filepath),$buffer) endif Does this works? Edited May 30, 2007 by c4nm7 Link to comment Share on other sites More sharing options...
autoitxp Posted May 31, 2007 Author Share Posted May 31, 2007 (edited) Hi Its not Receiving complete data stream and Function _tcprecv() not useable after click . Edited May 31, 2007 by autoitxp 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