New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: Checking errors for EPIPE and ECONNRESET requires syscall #8319

Open
PieterD opened this Issue Jul 2, 2014 · 4 comments

Comments

Projects
None yet
5 participants
@PieterD
Contributor

PieterD commented Jul 2, 2014

Reading and writing can cause EPIPE and ECONNRESET to be returned in addition to io.EOF.

_, err := conn.Write(data)
if oe, ok := err.(*net.OpError); ok && (oe.Err == syscall.EPIPE || oe.Err ==
syscall.ECONNRESET) {
    return fmt.Errorf("Connection closed")
}

_, err := conn.Read(data)
oe, ok := err.(*net.OpError)
if err == io.EOF || ok && oe.Err == syscall.ECONNRESET {
    return fmt.Errorf("Connection closed")
}

This isn't the neatest solution, and if we're going to freeze and possibly internalize
syscall, this is going to have to go.

Perhaps something similar to os.IsExist? I'm thinking net.IsReset or net.IsClosed.

Or we could simply return io.EOF for both. I don't know.

And what about other operating systems? Do they have similar problems?
@ianlancetaylor

This comment has been minimized.

Contributor

ianlancetaylor commented Jul 2, 2014

Comment 1:

Labels changed: added repo-main, release-go1.4.

@rsc

This comment has been minimized.

Contributor

rsc commented Sep 15, 2014

Comment 2:

Status changed to Thinking.

@rsc

This comment has been minimized.

Contributor

rsc commented Oct 28, 2014

Comment 3:

I don't know what to do about this. 
We could use io.ErrUnexpectedEOF for Read, and maybe for Write too. Unclear.
I'm not thrilled about hacks in net because writing to pipes has the same problem.
But I'm not thrilled about hacks in os either.
Leaving for 1.5.

Labels changed: added release-go1.5, removed release-go1.4.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014

@bradfitz bradfitz removed the release-go1.5 label Dec 16, 2014

@rsc rsc removed the repo-main label Apr 14, 2015

@rsc rsc modified the milestones: Unplanned, Go1.5 Jul 15, 2015

jonaz referenced this issue in stampzilla/stampzilla-go Aug 17, 2015

@bsed

This comment has been minimized.

bsed commented Oct 13, 2017

"readfull EOF:*net.OpError read tcp 172.19.13.222:51753->172.19.5.50:9091: wsarecv: An established connection was aborted by the software in your host machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment