tcp icon indicating copy to clipboard operation
tcp copied to clipboard

allow using a wrapped net.TCPConn in NewConn

Open marten-seemann opened this issue 4 years ago • 2 comments

Currently, the connection passed to NewConn has to be a *net.TCPConn, even though the function allows for a net.Conn to be passed. This is because NewConn performs a type assertion: https://github.com/mikioh/tcp/blob/803a9b46060c1d8b9ee03ff0386b87c179f50227/rawconn.go#L99-L112

It would be nice if it was possible to pass a wrapped *net.TCPConn to NewConn. This should be a problem, as the only function actually needed is SyscallConn(). By doing an interface assertion using an interface only fulfilled by a net.TCPConn, we can even make sure that we don't accidentally use this package with a connection that's not a TCP connection.

marten-seemann avatar Feb 23 '21 02:02 marten-seemann

@mikioh Any thought about this PR?

marten-seemann avatar Mar 05 '21 09:03 marten-seemann

@mikioh Friendly ping. It would be really great if we could get this PR merged soon, I'd hate to fork this project for such a minor change.

marten-seemann avatar Mar 27 '21 05:03 marten-seemann