#include 'WSA_NBTCP.au3' Opt('MustDeclareVars', 1) Opt('TrayAutoPause', 0) ; ; ;=== IP And Port Settings === Local $sLocalIP = '127.0.0.1' Local $nLocalPort = '61000' ;============================ ; ; Local Const $sTitle = 'AutoIt v' & @AutoItVersion & ' - WSA_TCPSend_Benchmark' TraySetToolTip($sTitle) ; If TCPStartup() <> 1 Then MsgBox(8208, $sTitle, 'Error: TCPStartup' & @TAB, 5) Exit EndIf ; Local $nSocket = _WSA_TCPConnect($sLocalIP, $nLocalPort) If @error Then MsgBox(8208, @error, 'Error: TCPConnect' & @TAB, 5) Exit EndIf ; ; Local $timer, $timerdiff, $nError, $nPause = 0 Local $nPlacement = (@DesktopWidth / 2) - 270 ; DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 1) Local $ID_GUI = GUICreate($sTitle, 320, 240, $nPlacement) GUICtrlCreateLabel('Packets Sent', 10, 12, 130, 20, 0x0002) Local $ID_IP1 = GUICtrlCreateInput(0, 150, 10, 130, 20, 0x0800) GUICtrlCreateLabel('TCPSend Speed (ms)', 10, 42, 130, 20, 0x0002) Local $ID_IP2 = GUICtrlCreateInput(0, 150, 40, 130, 20, 0x0800) GUICtrlCreateLabel('Errors', 10, 72, 130, 20, 0x0002) Local $ID_IP3 = GUICtrlCreateInput(0, 150, 70, 130, 20, 0x0800) Local $ID_BTN = GUICtrlCreateButton('Simulate Server Delay', 100, 150, 130, 30) GUICtrlSetOnEvent($ID_BTN, 'TogglePause') GUISetOnEvent(-3, 'ExitApp') GUISetState(@SW_SHOW, $ID_GUI) OnAutoItExitRegister('ExitApp') Opt('GUIOnEventMode', 1) ; Local $string = '' For $i = 1 To 10240; 1MB String $string &= 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; 100 characters Next ; ; 1 megabyte chunks * 100 loop sends = 100 megabytes ; ; possible one line header format ; Local $sHeader = '
Content:text;Type:string;FileName:example.txt;Bytes:512
' & @CRLF ; For $i = 1 To 100 $timer = TimerInit() ; _WSA_TCPSend($nSocket, $string) $nError = @error ; GUICtrlSetData($ID_IP1, $i) GUICtrlSetData($ID_IP2, Round(TimerDiff($timer), 2)) ; If $nError Then TCPCloseSocket($nSocket) GUICtrlSetData($ID_IP3, $nError) MsgBox(0, 'TCPSend Error', _WSA_FormatMessage($nError)) ExitLoop EndIf ; While $nPause Sleep(10) WEnd Next ; Func TogglePause() If $nPause = 0 Then $nPause = 1 Else $nPause = 0 EndIf EndFunc ; Func ExitApp() Sleep(1000) GUIDelete($ID_GUI) TCPCloseSocket($nSocket) TCPShutdown() Exit EndFunc ;