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
ReadorWrite.- this is partly because
Readassigns 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.Connto serializeReads andWrites using my favoriteio.Pipe-with-goroutine trick - transforms websocket.CloseError with code
CloseNormalClosureorCloseNoStatusReceivedtoio.EOF - implements the remaining
net.Connmethods