github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/tcp/stream-recv.go (about) 1 /* For license and copyright information please see the LEGAL file in the code repository */ 2 3 package tcp 4 5 import ( 6 "github.com/GeniusesGroup/libgo/buffer" 7 "github.com/GeniusesGroup/libgo/protocol" 8 "github.com/GeniusesGroup/libgo/timer" 9 ) 10 11 // recv is receive sequence space 12 type recv struct { 13 readTimer timer.Timer // read deadline timer 14 15 next uint32 // receive next 16 wnd uint16 // receive window 17 up bool // receive urgent pointer 18 irs uint32 // initial receive sequence number 19 // TODO::: not in order segments 20 buf buffer.Queue 21 22 // TODO::: Send more than these flags: push, reset, finish, urgent 23 flag chan flag 24 } 25 26 func (r *recv) init(timeout protocol.Duration) { 27 r.flag = make(chan flag, 1) // 1 buffer slot?? 28 29 r.readTimer.Init(nil) 30 r.readTimer.Start(timeout) 31 32 // TODO::: 33 } 34 35 // sendFlagSignal use to notify listener in the r.flag channel 36 func (r *recv) sendFlagSignal(f flag) { 37 select { 38 case r.flag <- f: 39 // nothing to do 40 default: 41 break 42 } 43 }