golang/go

net: writing to TCP socket returns incorrect number of bytes upon timeout on Windows

Open

#24,727 建立於 2018年4月6日

在 GitHub 查看
 (7 留言) (0 反應) (0 負責人)Go (19,008 fork)batch import
NeedsInvestigationOS-Windowshelp wanted

倉庫指標

Star
 (133,883 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10.1 windows/amd64

Does this issue reproduce with the latest release?

Yes - it seems to have been there for ages.

What operating system and processor architecture are you using (go env)?

I use Windows 10 64 bit.

What did you do?

The easiest way to see and reproduce the problem is by using the proof-of-concept tools.

First the server part - you can download it from here: https://pastebin.com/NUdxuMDw Start the server on any PC that has TCP port 11111 open and accessible. OS of the server machine does not matter.

Now download the actual test client: https://pastebin.com/SFQyyHfb Run the test client on Windows. You just need to specify one parameter on the command line: IP or host name of your running server (the one with open TCP port 11111).

The test is supposed to send 1MB of data to the server. But you will see that it actually sends more....

The reason for it, is that whenever the Write() function returns a timeout, it always returns n=0. Which seems to be wrong, as you can sometimes see some data going through.

This problem does not occur when you run the same code on Linux (there you can actually see n>0 being returned). I have not checked other platforms.

What did you expect to see?

Always 1MB of data received at the server side.

What did you see instead?

More than 1MB of data received at the server side.

貢獻者指南