github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/tcp/socket-recv.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package tcp
     4  
     5  import (
     6  	"../buffer"
     7  )
     8  
     9  // Receive Sequence Space
    10  //
    11  // 1          2          3
    12  // ----------|----------|----------
    13  //    RCV.NXT    RCV.NXT
    14  // 			 +RCV.WND
    15  //
    16  // 1 - old sequence numbers which have been acknowledged
    17  // 2 - sequence numbers allowed for new reception
    18  // 3 - future sequence numbers which are not yet allowed
    19  type recvSequenceSpace struct {
    20  	next uint32 // receive next
    21  	wnd  uint16 // receive window
    22  	up   bool   // receive urgent pointer
    23  	irs  uint32 // initial receive sequence number
    24  	// TODO::: not in order segments
    25  	buf buffer.Queue
    26  
    27  	// TODO::: Send more than these flags: push, reset, finish, urgent
    28  	flag chan flag
    29  }
    30  
    31  func (r *recvSequenceSpace) init() {
    32  	r.flag = make(chan flag, 1)
    33  	// TODO:::
    34  }
    35  
    36  // sendFlagSignal use to notify listener in the r.flag channel
    37  func (r *recvSequenceSpace) sendFlagSignal(f flag) {
    38  	select {
    39  	case r.flag <- f:
    40  		// nothing to do
    41  	default:
    42  		break
    43  	}
    44  }