﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
2513	TCPSend() Not functioning with string over 225 characters in length.	NullSchritt		"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

}}}

"	Bug	closed		AutoIt	3.3.9.21	None	Rejected		
