Opened 5 years ago

Closed 2 years ago

#3572 closed Bug (Works For Me)

TCPSend can hang forever without returning an error

Reported by: ferbfletcher Owned by: Jpm
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:


See this forum post for additional information:

When TCPSend is called in a loop, (without closing the socket and opening it each time), TCPSend seems to hang forever after a certain amount of data has been sent. This seems to have no relationship to how fast or slow the data is sent, or how large the data is, other than the fact that if you send the data slower or at a lower amount of data, it will take longer to see the hang.

This was first discovered by sending data to a proprietary non-autoit 3rd-party tcp server, which I have no control over, and which I have no way to see how that server is configured. However, the autoit server code included here causes the same client hang.

Please note that the server code included here is not the code in question, and is only included so that the client will run and hang.

Server Code, make sure this is running before starting the client code. The server code and the client code can be ran on the same PC.


$iListenSocket = TCPListen("", 500, 100)

  $iSocket = TCPAccept($iListenSocket)
Until $iSocket <> -1 ;if different from -1 a client is connected.

while 1
  $sReceived = TCPRecv($iSocket,100)



$iSocket = TCPConnect("", 500)
$x = 0
Local $mydata

;This is to make some data for testing purposes
For $a = 1 to 100
  $mydata &= "xxxxxxxxxxxxxxxxxxxx"

While 1
  $x += 1
  TCPSend($iSocket, $mydata)
  If @error <> 0 Then MsgBox(0,"Error",@error)
  ToolTip($x) ;this is for a visual indication of program running

If it appears that I am sending an unrealistic amount of data at an unrealistic speed, that's true, but it shows the hang faster. If you lower the data size and slow down the sending rate, the hang will still happen after the same amount of data has been sent but you will have to wait much longer for that amount of data to be sent.

The coding method may not be perfect, but the reason I am posting this as a bug is because TCPSend should NEVER hang forever. If there is an issue, it should instead return an error. However, there is no error returned, it just hangs. That makes it appear to be a bug within TCPSend, where some sending issue is not properly being caught. If caught, it could return an error and the program could deal with that error.

Attachments (0)

Change History (4)

comment:1 Changed 5 years ago by fer

I am currently using version when the hanging happens.

This does NOT happen in

Here is what happens in After it reaches that hanging point, it hangs for a few seconds, and then it continues for awhile, and then it hangs for a few seconds, and then it continues for awhile.

So, it seems that is retrying after the server stops accepting data, and then it successfully continues sending when the server is ready again, while simply hangs forever if the server stops accepting data for some reason (buffer full or whatever reason).

It should either return an error, or successfully retry like does. Hanging forever is not good.

comment:2 Changed 5 years ago by ferbfletcher

This seems to be specific to Windows 8 and Windows 10.

comment:3 Changed 4 years ago by Jpm

  • Owner set to Jpm
  • Status changed from new to assigned

comment:4 Changed 2 years ago by Jpm

  • Resolution set to Works For Me
  • Status changed from assigned to closed

Hi I think the problem is closed just try the TCPSend/ TCPRecv second example using a big file

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.

Add Comment

Modify Ticket

as closed The owner will remain Jpm.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.