refactor the code related to xtcp (#3449)

This commit is contained in:
fatedier authored and GitHub committed 2023-05-28 16:50:43 +08:00
1 parent 9f029e3248
commit c71efde303
44 files changed
+3305 -1699

No files matched your search

+8
View File
@@ -256,3 +256,11 @@ func (l *UDPListener) Close() error {
func (l *UDPListener) Addr() net.Addr {
return l.addr
}
// ConnectedUDPConn is a wrapper for net.UDPConn which converts WriteTo syscalls
// to Write syscalls that are 4 times faster on some OS'es. This should only be
// used for connections that were produced by a net.Dial* call.
type ConnectedUDPConn struct{ *net.UDPConn }
// WriteTo redirects all writes to the Write syscall, which is 4 times faster.
func (c *ConnectedUDPConn) WriteTo(b []byte, addr net.Addr) (int, error) { return c.Write(b) }