Go version
go version go1.22.0 linux/amd64
Output of go env in your module/workspace:
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
Go version
go version go1.22.0 linux/amd64
Output of
go envin your module/workspace: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:
FINreceived from client to server and vice versa.RSTbeen received from either client or server.What did you see happen?
I can send
FINby callingconn.CloseWrite()but I can't distinguish half-closed from closed tcp connection usingconn.Read. All I got isio.EOF, I need to know whether it's half-closed or not so I can make decision to callconn.CloseWrite()orconn.Close().Reading the source code indicate that the information is lost in src/runtime/netpoll_epoll.go: netpoll which checked
syscall.EPOLLRDHUPwith a bunch of other flagsWhat did you expect to see?
Able to wait for half-close and close event for tcp connection