-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Since you spawn a goroutine for each send, if the buffers are reused by the application after sending (like in KCP library we use), they will get garbled potentially before sending. I suggest either noting in the documentation that one needs to copy buffers before calling WriteTo() or adding an explicit copy before making a goroutine:
func (c *packetConn) WriteTo(bts []byte, addr net.Addr) (int, error) {
...
p := make([]byte, len(bts))
copy(p, bts)
go func() {
...
https://github.com/cevatbarisyilmaz/lossy/blob/master/packet_conn.go#L69
conn.go has the same issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels