Source File
nonquic_packetconn.go
Belonging Package
github.com/libp2p/go-libp2p/p2p/transport/quicreuse
package quicreuseimport ()// nonQUICPacketConn is a net.PacketConn that can be used to read and write// non-QUIC packets on a quic.Transport. This lets us reuse this UDP port for// other transports like WebRTC.type nonQUICPacketConn struct {owningTransport RefCountedQUICTransporttr QUICTransportctx context.ContextctxCancel context.CancelFuncreadCtx context.ContextreadCancel context.CancelFunc}// Close implements net.PacketConn.func ( *nonQUICPacketConn) () error {.ctxCancel()// Don't actually close the underlying transport since someone else might be using it.// reuse has it's own gc to close unused transports..owningTransport.DecreaseCount()return nil}// LocalAddr implements net.PacketConn.func ( *nonQUICPacketConn) () net.Addr {return .owningTransport.LocalAddr()}// ReadFrom implements net.PacketConn.func ( *nonQUICPacketConn) ( []byte) (int, net.Addr, error) {:= .readCtxif == nil {= .ctx}return .tr.ReadNonQUICPacket(, )}// SetDeadline implements net.PacketConn.func ( *nonQUICPacketConn) ( time.Time) error {// Only used for reads.return .SetReadDeadline()}// SetReadDeadline implements net.PacketConn.func ( *nonQUICPacketConn) ( time.Time) error {if .IsZero() && .readCtx != nil {.readCancel().readCtx = nil}.readCtx, .readCancel = context.WithDeadline(.ctx, )return nil}// SetWriteDeadline implements net.PacketConn.func ( *nonQUICPacketConn) ( time.Time) error {// Unused. quic-go doesn't support deadlines for writes.return nil}// WriteTo implements net.PacketConn.func ( *nonQUICPacketConn) ( []byte, net.Addr) (int, error) {return .tr.WriteTo(, )}var _ net.PacketConn = &nonQUICPacketConn{}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |