Skrip Posted February 2, 2009 Share Posted February 2, 2009 (edited) Please help, it cannot connect. To use: Run the server, start the server, paste the Connect code onto the client and click connect. Server.au3 expandcollapse popup#Region _Startup/Vars/Includes #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <String.au3> #include <INet.au3> ;; $Auth = 0 $port = 666 ;~ $connected = 0 $cConnected = 0 $started = 0 Dim $hSocket, $cSocket, $socket #EndRegion _Startup/Vars/Includes TCPStartup() #Region GUI $gForm1 = GUICreate("Computer Information (Server)", 625, 440) $gLabel1 = GUICtrlCreateLabel("Connection Code:", 8, 10, 89, 17) $gLabel2 = GUICtrlCreateLabel("Auth Code:", 8, 34, 57, 17) $gLabel3 = GUICtrlCreateLabel("Port:", 488, 10) $gInput1 = GUICtrlCreateInput("Please start the server.", 104, 8, 377, 21) $gInput2 = GUICtrlCreateInput("Please start the server.", 104, 32, 377, 21) $gInput3 = GUICtrlCreateInput($port, 515, 8, 40) $gButton1 = GUICtrlCreateButton("Regenerate", 488, 31, 129, 25, 0) $gStart = GUICtrlCreateButton("Start Server", 560, 7, 60, 21) $gEdit1 = GUICtrlCreateEdit("", 8, 208, 609, 193) GUICtrlSetData(-1, "Recieved Information:") $gButton2 = GUICtrlCreateButton("Send Info Request", 8, 408, 129, 25, 0) $gButton3 = GUICtrlCreateButton("Save Information", 448, 408, 129, 25, 0) $gConsole = GUICtrlCreateEdit("", 8, 56, 609, 145, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, @CRLF & "Waiting...") $gButton4 = GUICtrlCreateButton("Clear Info", 144, 408, 137, 25, 0) $gButton5 = GUICtrlCreateButton("Disconnect", 300, 408, 129, 25, 0) $gconnected = GUICtrlCreateInput("", 600, 408, 23, 23, BitOR($ES_AUTOHSCROLL, $ES_READONLY)) GUICtrlSetBkColor(-1, 0xFF0000) GUISetState(@SW_SHOW) ;Disable Stuff ControlDisable($gForm1, "", $gButton1) ControlDisable($gForm1, "", $gButton2) ControlDisable($gForm1, "", $gButton3) ControlDisable($gForm1, "", $gButton4) ControlDisable($gForm1, "", $gButton5) While 1 $Csocket = TCPAccept($hSocket) ;~ $Csocket = TCPAccept($hClient) $Cmsg = TCPRecv($Csocket, 1024) If StringLen($Cmsg) Then _Receive($Cmsg) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $gStart GUICtrlSetData($gInput1, _StringEncrypt(1, _GetIP() & "|" & GUICtrlRead($gInput3), "Ganji", 2)) $CAuth = _StringEncrypt(1, Random(0, 9999, 1), "Tundra", 5) GUICtrlSetData($gInput2, $CAuth) ControlDisable($gForm1, "", $gInput3) ControlDisable($gForm1, "", $gStart) $hSocket = TCPListen(@IPAddress1, GUICtrlRead($gInput3)) _CW("Server started. Waiting for connection on port " & GUICtrlRead($gInput3) & ".") If $hSocket = -1 or $hSocket = 1 Or $hSocket = 2 Then _CW("Error: " & @error) EndIf $started = 1 Case $gButton1 $CAuth = _StringEncrypt(1, Random(0, 9999, 1), "Tundra", 5) GUICtrlSetData($gInput2, $CAuth) Case $gButton2 TCPSend($Csocket, "InRq") _CW("Information Request Sent...") Case $gButton3 _CW("Beginning file writing...") $SFile = FileOpen(@DesktopDir & "/" & "RecievedInformation.txt", 1) FileWrite($SFile, "Generated on: " & @MDAY & "/" & @MON & "/" & @YEAR & " At: " & @HOUR & ":" & @MIN & ":" & @SEC) FileWrite($SFile, GUICtrlRead($gEdit1)) FileClose($SFile) _CW("Completed. File located at " & @DesktopDir & "\" & "RecievedInformation.txt") Case $gButton4 _CW("Cleared information...") GUICtrlSetData($gEdit1, "") Case $gButton5 TCPSend($hSocket, "DC") Sleep(500) _CW("Disconnected Client.") EndSwitch WEnd #EndRegion GUI Func _CW($ConsoleText) GUICtrlSetData($gConsole, @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & "->" & $ConsoleText & GUICtrlRead($gConsole)) EndFunc;==>_CW Func _Receive($Cmsg) If StringInStr($msg, "Msg") Then MsgBox(0, "", "Worked.") TCPSend($hClient, "Test") EndIf EndFunc;==>_Receive Client: expandcollapse popup#Region _Startup/Vars/Includes #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <String.au3> ;; $CRecieved = "" $debug = 0 $started = 0 Global $hClient #EndRegion _Startup/Vars/Includes TCPStartup() $ipAddress = @IPAddress1 #Region GUI $Form1 = GUICreate("Computer Information (Client)", 361, 171) $Label1 = GUICtrlCreateLabel("Enter Connect Code:", 8, 10, 103, 17) $Input1 = GUICtrlCreateInput("", 136, 8, 217, 21) $Label2 = GUICtrlCreateLabel("Enter Authorization Code:", 8, 34, 124, 17) $Input2 = GUICtrlCreateInput("", 136, 32, 217, 21) $Button1 = GUICtrlCreateButton("Connect", 256, 56, 97, 25, 0) $Label3 = GUICtrlCreateLabel("Support Type:", 8, 58, 71, 17) $Input3 = GUICtrlCreateInput("ALL", 136, 56, 113, 21) GUICtrlSetState(-1, $GUI_DISABLE) $Console = GUICtrlCreateEdit("", 0, 88, 360, 82, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, @CRLF & "Please enter information and click connect...") If $debug = 1 Then GUICtrlSetData($Input1, "Enter the port in this field. (Default: 666)") If $debug = 1 Then _CW("Debug mode is ENABLED. The client will attempt to connect to local computer.") GUISetState(@SW_SHOW) $err = 0 While 1 $Csocket = TCPAccept($hClient) $Cmsg = TCPRecv($Csocket, 1024) If StringLen($Cmsg) Then _Receive($Cmsg) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1; Connect _CW("Connecting...") $CID = _StringEncrypt(0, GUICtrlRead($Input1), "Ganji", 2) $CID = StringSplit($CID, "|") $CAuth = GUICtrlRead($Input2) $hClient = TCPConnect($CID[1], $CID[2]);IPAddress, Port MsgBox(0, "", $CID[1] & " | " & $CID[2], 10) If $hClient = -1 or $hClient = 1 or $hClient = 2 Then _CW("Error: " & @error) EndIf EndSwitch WEnd #EndRegion GUI Func _CW($ConsoleText) GUICtrlSetData($Console, @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & "->" & $ConsoleText & GUICtrlRead($Console)) EndFunc ;==>_CW Func _Receive($Cmsg) If StringInStr($msg, "Msg") Then MsgBox(0, "", "Worked.") TCPSend($hClient, "Test") EndIf EndFunc ;==>_Receive Edited February 3, 2009 by Firestorm [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 3, 2009 Moderators Share Posted February 3, 2009 TCPConnect() for the client? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Skrip Posted February 3, 2009 Author Share Posted February 3, 2009 Yes. Shouldn't the client connect to the server? [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 3, 2009 Moderators Share Posted February 3, 2009 (edited) Yes. Shouldn't the client connect to the server?I don't see where you're using TCPConnect() or maybe I'm blind.Edit:Ahh I see... When you connect there, at that exact point, what is the error?If it's failing there, make sure you've forwarded your port that you're using. Edited February 3, 2009 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Skrip Posted February 3, 2009 Author Share Posted February 3, 2009 I've forwarded everything. The port works (Testing on port 666). No error is thrown. It just...doesn't connect. [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 3, 2009 Moderators Share Posted February 3, 2009 (edited) I've forwarded everything. The port works (Testing on port 666). No error is thrown. It just...doesn't connect.Ehh... it's a mess ... you should initiate with tcplisten before the loop, you assume everything is connected, you're using undeclared or unused variables. Just a mess.Edit:I suggest you tear apart some Example forum scripts that show server and clients. And think through the logic you're using to call functions. Edited February 3, 2009 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Skrip Posted February 3, 2009 Author Share Posted February 3, 2009 Ehh... it's a mess ... you should initiate with tcplisten before the loop, you assume everything is connected, you're using undeclared or unused variables. Just a mess.Yeah. I was trying to combine two scripts...and one of them used Kips TCP functions. But those don't seem to work for me. I was thinking i'd have to restart. It's probably for the best. [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] 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