@@ -123,24 +123,17 @@ it has to reinvent hooks for TLS and proxies and prevents support of HTTP/2.
123123Some more advantages of nhooyr/websocket are that it supports concurrent writes and
124124makes it very easy to close the connection with a status code and reason.
125125
126- nhooyr/websocket also responds to pings, pongs and close frames in a separate goroutine so that
127- your application doesn't always need to read from the connection unless it expects a data message.
128- gorilla/websocket requires you to constantly read from the connection to respond to control frames
129- even if you don't expect the peer to send any messages.
130- 
131126The ping API is also much nicer. gorilla/websocket requires registering a pong handler on the Conn
132127which results in awkward control flow. With nhooyr/websocket you use the Ping method on the Conn
133128that sends a ping and also waits for the pong.
134129
135- In terms of performance, the differences depend on your application code. nhooyr/websocket
136- reuses buffers efficiently out of the box if you use the wsjson and wspb subpackages whereas
137- gorilla/websocket does not. As mentioned above, nhooyr/websocket also supports concurrent
138- writers out of the box.
130+ In terms of performance, the differences mostly depend on your application code. nhooyr/websocket
131+ reuses message buffers out of the box if you use the wsjson and wspb subpackages.
132+ As mentioned above, nhooyr/websocket also supports concurrent writers.
139133
140- The only performance con to nhooyr/websocket is that uses two extra goroutines. One for
141- reading pings, pongs and close frames async to application code and another to support
142- context.Context cancellation. This costs 4 KB of memory which is cheap compared
143- to the benefits.
134+ The only performance con to nhooyr/websocket is that uses one extra goroutine to support
135+ cancellation with context.Context and the net/http client side body upgrade.
136+ This costs 2 KB of memory which is cheap compared to simplicity benefits.
144137
145138### x/net/websocket  
146139
0 commit comments