﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
2596	TCPRecv not returning data, and setting @error to -1	diegomainster@…	Jpm	"Hello, sorry for my english, I'm using a translator.

I would like to inform that the TCPRecv is not returning data, and are setting @error to -1. I noticed this problem in version 3.3.10.0, updated today to version 3.3.10.2 and still continues. The problem is not in my notebook because it tested in another, and not in my script, it works with version 3.3.8.1. A script to test I'm using is this:


{{{
TCPStartup()
;if I set $ip with a local address or a nearby site, such as the provider, TCPRecv works most of the time, but sometimes not
$ip = TCPNameToIP('www.google.com')
If @error Then erro('TCPNameToIP', @error)
$tc = TCPConnect($ip, 80)
If @error Then erro('TCPConnect', @error)
TCPSend($tc, 'GET / HTTP/1.1' & @CRLF & 'Host: www.google.com' & @CRLF & 'Connection: close' & @CRLF & @CRLF)
If @error Then erro('TCPSend', @error, 1)
$tr = ''
$ti = TimerInit()
Do
   $tr &= TCPRecv($tc, 1)
   If @error Then erro('TCPRecv', @error, 1)
   If TimerDiff($ti) > 9999 Then erro('Timeout', '', 1)
Until StringInStr($tr, @CRLF & @CRLF)
MsgBox(0, 'Receive Header:', $tr)
$tr = ''
$ti = TimerInit()
While 1
   $tr &= TCPRecv($tc, 1480)
   If @error Or TimerDiff($ti) > 9999 Then ExitLoop
WEnd
MsgBox(0, 'Receive Content:', $tr)
TCPCloseSocket($tc)

Func erro($f, $e, $c = 0)
   MsgBox(16, 'Erro:', 'Function ' & $f & @LF & '@error = ' & $e)
   If $c Then TCPCloseSocket($tc)
   TCPShutdown()
   Exit
EndFunc
}}}

If I call the Sleep() before TCPRecv with a greater than or equal to 500ms time (sometimes works with a shorter time), the TCPRecv returns data, and not sets @error, as in the following script:


{{{
TCPStartup()
;if I set $ip with a local address or a nearby site, such as the provider, TCPRecv works most of the time, but sometimes not
$ip = TCPNameToIP('www.google.com')
If @error Then erro('TCPNameToIP', @error)
$tc = TCPConnect($ip, 80)
If @error Then erro('TCPConnect', @error)
TCPSend($tc, 'GET / HTTP/1.1' & @CRLF & 'Host: www.google.com' & @CRLF & 'Connection: close' & @CRLF & @CRLF)
If @error Then erro('TCPSend', @error, 1)
$tr = ''

;with sleep work
Sleep(500)

$ti = TimerInit()
Do
   $tr &= TCPRecv($tc, 1)
   If @error Then erro('TCPRecv', @error, 1)
   If TimerDiff($ti) > 9999 Then erro('Timeout', '', 1)
Until StringInStr($tr, @CRLF & @CRLF)
MsgBox(0, 'Receive Header:', $tr)
$tr = ''
$ti = TimerInit()
While 1
   $tr &= TCPRecv($tc, 1480)
   If @error Or TimerDiff($ti) > 9999 Then ExitLoop
WEnd
MsgBox(0, 'Receive Content:', $tr)
TCPCloseSocket($tc)

Func erro($f, $e, $c = 0)
   MsgBox(16, 'Erro:', 'Function ' & $f & @LF & '@error = ' & $e)
   If $c Then TCPCloseSocket($tc)
   TCPShutdown()
   Exit
EndFunc
}}}
"	Bug	closed		AutoIt	3.3.10.2	None	Works For Me		
