hashicorp/yamux

Is Session.Accept Result Really Compatible With net.Conn?

kudla opened this issue · 2 comments

kudla commented

Hi
A Session instance returns Stream one from Accept call as a net.Conn here

Yet net.Conn among the rest defines

	// LocalAddr returns the local network address, if known.
	LocalAddr() Addr

	// RemoteAddr returns the remote network address, if known.
	RemoteAddr() Addr

which Stream seems like doesn't implement.

So I'm not really sure how this is compiled at all (while it indeed is)?

But my main concern here how can the accepted connection be passed to other consumers which are really supposed to have a pure net.Conn?

Should I wrap with some stubs the connections myself? Or are there any intended solution for that?

Thx.

Hi,

Stream implements net.Conn (and its LocalAddr and RemoteAddr methods, of course). There is no way for a type to partially implement an interface. Those methods are implemented in addr.go.

kudla commented

Ah, I see. Thank you 👍