Comments (3)
Sigh, I don't remember the reason why I do not check the written bytes.
Maybe I mistaken File.Write
's doc for TCPConn.Write
. Or maybe I thought it should confirm to the io.Writer
interface. Both of these two Write
return a non-nil error if it returns n < len(p).
It would be awkward to use loop for every socket write, but I am not sure TCPConn.Write
has the same guarantee now ...
I'll have further check on this issue.
from shadowsocks-go.
http://golang.org/src/net/fd_unix.go?h=Write#L317
line 331
if nn == len(p) {
break
}
If the write operation succeeds the n that TCPConn.Write returns should be equal to len(buf), otherwise a Non-nil err should be returned.
I think Google has already implemented the loop.
from shadowsocks-go.
Thanks @lixin9311 for pointing this out.
I was actually reading the Write
function when posting the last reply, and should have read the function before when I tried to port Go's net package to Lua in luanet. But I just ignored the loop, symptom for working for too long these days ...
For future reference, I'll include the write function here.
func (fd *netFD) Write(p []byte) (nn int, err error) {
if err := fd.writeLock(); err != nil {
return 0, err
}
defer fd.writeUnlock()
if err := fd.pd.PrepareWrite(); err != nil {
return 0, &OpError{"write", fd.net, fd.raddr, err}
}
for {
var n int
n, err = syscall.Write(int(fd.sysfd), p[nn:])
if n > 0 {
nn += n
}
if nn == len(p) {
break
}
if err == syscall.EAGAIN {
if err = fd.pd.WaitWrite(); err == nil {
continue
}
}
if err != nil {
n = 0
break
}
if n == 0 {
err = io.ErrUnexpectedEOF
break
}
}
if err != nil {
err = &OpError{"write", fd.net, fd.raddr, err}
}
return nn, err
}
from shadowsocks-go.
Related Issues (20)
- CodeLingo Install
- 求解 HOT 3
- support IPv6 in client-multi-server.json HOT 4
- EOF error HOT 2
- The ss server goes dead frequently
- traffic for port reported too low HOT 2
- 数组切割错误runtime error: slice bounds out of range HOT 2
- panic了一次,udp
- How to get shadowsocks log file on windows server?
- Server copies client IV
- go get 总是报 “ TLS handshake timeout” 错误 HOT 3
- script/build.sh 执行报错 could not determine kind of name for C.AI_MASK
- 通过命令行启动的时候,没有读取config.json里面加密方法,而是使用了默认的加密方法 HOT 1
- 请问go在监听端口的时候,有没有办法在代码里面去设置backlog等待队列的值? HOT 1
- aes-128-cfb 加密算法问题
- 请问是否有debug模式启动,can i start it with debug mode
- 要不要试试flynet?
- "XML syntax error" causing go get to fail. HOT 1
- 找大佬合作开发下定制客户端
- SS_client is not forwarding SIP Traffic to SS_Server
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shadowsocks-go.