xRemy Posted October 29, 2018 Posted October 29, 2018 I'm trying to make a bot for a game using TCP packets for learning purposes, however there are a few issues when i send data im getting this error: "TCPSend(^ ERROR" The code was originally copied and pasted but i made a lot of modifications to it. I believe it worked before i added a GUI and such. My second problem is once i do send data without error the port where i need to listen on is random, how do i get that info? Here is my code so far: expandcollapse popupglobal $bet = "19.6.G_BJ_PLUGIN.1.t.t.t.. " global $join = "6.29715.http://a2.cdn.gaiaonline.com/gaia/members/ava/f7/6c/8f03a8192406cf7.swf.0.0.0.0.0.0.0.0.0.6.29715.http://a2.cdn.gaiaonline.com/gaia/members/ava/f7/6c/8f03a8192406cf7.swf.1.0.0.0.0.0.0.0.0.19.4.G_BJ_PLUGIN.11.82ciowufdi533cd5a354adca16rjgdjx40ovas97u9gj9jda.4.14.." ;325 global $dummy = "62..." TCPStartup() global $g_ip = "208.85.93.167" global $g_port = 8080 #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\Remy\Desktop\koda_1.7.2.0\Forms\Form1.kxf Global $Form1 = GUICreate("TCP SEND/RECV", 235, 354, 192, 124) Global $Input1 = GUICtrlCreateInput("Port", 0, 0, 145, 21) Global $Button1 = GUICtrlCreateButton("Listen", 152, 0, 75, 25) Global $Group1 = GUICtrlCreateGroup("Sends", 0, 24, 225, 97) Global $Button2 = GUICtrlCreateButton("Join", 8, 40, 75, 25) Global $Button3 = GUICtrlCreateButton("Bet", 8, 64, 75, 25) Global $Button4 = GUICtrlCreateButton("Dummy", 8, 88, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) Global $Edit1 = GUICtrlCreateEdit("", 8, 152, 217, 185) GUICtrlSetData(-1, "Edit1") Global $Label1 = GUICtrlCreateLabel("Response", 8, 128, 52, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Close() Case $Form1 Case $Input1 Case $Button1 global $port = $Input1 Case $Button2 global $data = $join Send_Data() Case $Button3 global $data = $bet Send_Data() Case $Button4 global $data = $dummy Send_Data() Case $Edit1 Case $Label1 EndSwitch WEnd $connect = TCPConnect($g_ip, $g_port) If @error Then ToolTip("could not connect to " & $g_ip) Sleep(5000) _Close() EndIf Func Send_Data() TCPSend($connect, $data) EndFunc Func _Close() TCPShutdown() Exit EndFunc $ip = "192.168.1.11" $listen = TCPListen($ip, $port) Func StartListen() While 1 $accept = TCPAccept($listen) If $accept <> -1 Then $Edit1 = $Edit1 & $accept & " has conncected" ExitLoop EndIf WEnd While 1 $recv = TCPRecv($accept, 1024) If @error Then;connection lost $Edit1 = $Edit1 & "lost connection between " & $accept EndIf If $recv <> "" Then;if received something $Edit1 = $Edit1 & "received this: '" & $recv & "'" Sleep(3000) EndIf WEnd EndFunc
xRemy Posted October 29, 2018 Author Posted October 29, 2018 IDK how to edit the original post. So i ended up adding $connect = TCPConnect($g_ip, $g_port) To my Send_Data() function and has seemed to fixed the issue on that part but im still confused on how i would go about getting the port to listen on.
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