Source File
stream.go
Belonging Package
github.com/quic-go/quic-go/internal/protocol
package protocolimport// StreamType encodes if this is a unidirectional or bidirectional streamtype StreamType uint8const (// StreamTypeUni is a unidirectional streamStreamTypeUni StreamType = iota// StreamTypeBidi is a bidirectional streamStreamTypeBidi)// InvalidPacketNumber is a stream ID that is invalid.// The first valid stream ID in QUIC is 0.const InvalidStreamID StreamID = -1// StreamNum is the stream numbertype StreamNum int64const (// InvalidStreamNum is an invalid stream number.InvalidStreamNum = -1// MaxStreamCount is the maximum stream count value that can be sent in MAX_STREAMS frames// and as the stream count in the transport parametersMaxStreamCount StreamNum = 1 << 60// MaxStreamID is the maximum stream IDMaxStreamID StreamID = quicvarint.Max)const (// FirstOutgoingBidiStreamClient is the first bidirectional stream opened by the clientFirstOutgoingBidiStreamClient StreamID = 0// FirstOutgoingUniStreamClient is the first unidirectional stream opened by the clientFirstOutgoingUniStreamClient StreamID = 2// FirstOutgoingBidiStreamServer is the first bidirectional stream opened by the serverFirstOutgoingBidiStreamServer StreamID = 1// FirstOutgoingUniStreamServer is the first unidirectional stream opened by the serverFirstOutgoingUniStreamServer StreamID = 3)const (// FirstIncomingBidiStreamServer is the first bidirectional stream accepted by the serverFirstIncomingBidiStreamServer = FirstOutgoingBidiStreamClient// FirstIncomingUniStreamServer is the first unidirectional stream accepted by the serverFirstIncomingUniStreamServer = FirstOutgoingUniStreamClient// FirstIncomingBidiStreamClient is the first bidirectional stream accepted by the clientFirstIncomingBidiStreamClient = FirstOutgoingBidiStreamServer// FirstIncomingUniStreamClient is the first unidirectional stream accepted by the clientFirstIncomingUniStreamClient = FirstOutgoingUniStreamServer)// StreamID calculates the stream ID.func ( StreamNum) ( StreamType, Perspective) StreamID {if == 0 {return InvalidStreamID}var StreamIDswitch {case StreamTypeBidi:switch {case PerspectiveClient:= 0case PerspectiveServer:= 1}case StreamTypeUni:switch {case PerspectiveClient:= 2case PerspectiveServer:= 3}}return + 4*StreamID(-1)}// A StreamID in QUICtype StreamID int64// InitiatedBy says if the stream was initiated by the client or by the serverfunc ( StreamID) () Perspective {if %2 == 0 {return PerspectiveClient}return PerspectiveServer}// Type says if this is a unidirectional or bidirectional streamfunc ( StreamID) () StreamType {if %4 >= 2 {return StreamTypeUni}return StreamTypeBidi}// StreamNum returns how many streams in total are below this// Example: for stream 9 it returns 3 (i.e. streams 1, 5 and 9)func ( StreamID) () StreamNum {return StreamNum(/4) + 1}
![]() |
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. |