Skip to content

net: no way to detect half-closed tcp connection #67337

@shinny-chengzhi

Description

@shinny-chengzhi

Go version

go version go1.22.0 linux/amd64

Output of go env in your module/workspace:

N/A

What did you do?

I'm trying to write a tcp proxy that accepting connection from client and proxy it to another server. The proxy should:

  • proxy data between client and server.
  • relay FIN received from client to server and vice versa.
  • close both legs of connection once RST been received from either client or server.

What did you see happen?

I can send FIN by calling conn.CloseWrite() but I can't distinguish half-closed from closed tcp connection using conn.Read. All I got is io.EOF, I need to know whether it's half-closed or not so I can make decision to call conn.CloseWrite() or conn.Close().
Reading the source code indicate that the information is lost in src/runtime/netpoll_epoll.go: netpoll which checked syscall.EPOLLRDHUP with a bunch of other flags

What did you expect to see?

Able to wait for half-close and close event for tcp connection

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions