Overhaul websocketconn.Conn; implement net.Conn
In the turbotunnel branch I found it convenient to have websocketconn.Conn
implement net.Conn
, not only io.ReadWriteCloser
. While implementing the additional methods, I found some ways that websocketconn.Conn
's existing methods do not satisfy the requirements of net.Conn
:
- there are data races when multiple goroutines call
Read
orWrite
.- this is partly because
Read
assigns to the shared fieldconn.r
, and partly because the underlying websocket.Conn doesn't permit concurrent access.
- this is partly because
- when a websocketconn.Conn is closed, it starts returning some kind of websocket.CloseError, not
io.EOF
.
This branch
- adds tests that expose the above issues
- rewrites
websocketconn.Conn
to serializeRead
s andWrite
s using my favoriteio.Pipe
-with-goroutine trick - transforms websocket.CloseError with code
CloseNormalClosure
orCloseNoStatusReceived
toio.EOF
- implements the remaining
net.Conn
methods