Opened 11 years ago
Closed 4 years ago
#2513 closed Bug (Rejected)
TCPSend() Not functioning with string over 225 characters in length.
Reported by: | NullSchritt | Owned by: | |
---|---|---|---|
Milestone: | Component: | AutoIt | |
Version: | 3.3.9.21 | Severity: | None |
Keywords: | Cc: |
Description
Hello I have found a bug that appears to be present in all the most recent beta releases of autoit, if TCPSend() is used with a string greater than 225 characters in length, all data is lost.
TCPSend Error Example:
TCPStartup() $ip = InputBox("Destination", "Destination IP") $sock = TCPConnect($ip, 7337) ;~ TCPSend($sock, "DATA TEST 1") $DT1 = "" for $i=1 to 225 $DT1 &= Random(1,9,1) Next TCPSend($sock, $DT1) ; this will be received properly $DT2 = "" for $i=1 to 226 $DT2 &= Random(1,9,1) Next TCPSend($sock, $DT2) ; this will be received as a blank string MsgBox(64, "Done", "Sent both packets")
Receive Script(modified from help file):
#include <GUIConstantsEx.au3> ; If you select the server button, start this script before and select the client button on: ; the second instance of this script OR on the example script TCPSend and vice versa. Example() Func Example() TCPStartup() ; Start the TCP service. ; Register OnAutoItExit to be called when the script is closed. OnAutoItExitRegister("OnAutoItExit") ; Assign Local variables the loopback IP Address and the Port. Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer. Local $iPort = 7337 ; Port used for the connection. #region GUI Local $hGUI = GUICreate("TCPRecv", 150, 70) Local $iBtnServer = GUICtrlCreateButton("1. Server", 10, 10, 130, 22) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iBtnServer _TCPRecv_Server($sIPAddress, $iPort) EndSwitch Sleep(10) WEnd #endregion GUI EndFunc ;==>Example Func _TCPRecv_Server($sIPAddress, $iPort) ConsoleWrite("Listening..."&@CRLF) ; Assign a Local variable the socket and bind to the IP Address and Port specified with a maximum of 100 pending connexions. Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100) Local $iError = 0 ; If an error occurred display the error code and return False. If @error Then ; Someone is probably already listening on this IP Address and Port (script already running?). $iError = @error MsgBox(64, "", "Server:" & @CRLF & "Could not listen, Error code: " & $iError) Return False EndIf ; Assign a Local variable to be used by the Client socket. Local $iSocket = 0 Do ; Wait for someone to connect (Unlimited). ; Accept incomming connexions if present (Socket to close when finished; one socket per client). $iSocket = TCPAccept($iListenSocket) Until $iSocket <> -1 ;if different from -1 a client is connected. ; Assign a Local variable the data received. Local $sReceived = TCPRecv($iSocket, 2048) ;we're waiting for the string "toto" OR "tata" (example script TCPSend): 4 bytes length. ; Display the string received. ConsoleWrite("Server:" & @CRLF & "Received: " & $sReceived&@CRLF) ; Close the socket. TCPCloseSocket($iSocket) TCPCloseSocket($iListenSocket) EndFunc ;==>_TCPRecv_Server Func OnAutoItExit() TCPShutdown() ; Close the TCP service. EndFunc ;==>OnAutoItExit
Attachments (2)
Change History (7)
comment:1 Changed 11 years ago by Jpm
comment:2 Changed 11 years ago by NullSchritt
This error does not always seem to be present, but occurs what seems rather randomly.
comment:3 Changed 11 years ago by Jpm
For me 226 is not the problem.
Almost sure your script does not handle more than one post
Changed 11 years ago by FireFox
Changed 11 years ago by FireFox
comment:4 Changed 11 years ago by FireFox
Please ignore the files I attached.
I created another ticket #2670 not to hijack this one.
comment:5 Changed 4 years ago by Jpm
- Resolution set to Rejected
- Status changed from new to closed
no more info so I close it
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
In fact the "problem" does not come from 225 to 226 but from the fact that such script is not design to handle several TCPSend()
I am not familiar with TCP usage so I cannot help more.