mirror of
https://github.com/soypat/lneto.git
synced 2026-08-19 14:14:07 +00:00
tcp.Conn:add Flush method and more lock protection
This commit is contained in:
+10
-1
@@ -228,7 +228,7 @@ func (h *Handler) Send(b []byte) (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
buffered := h.bufTx.Buffered()
|
||||
buffered := h.bufTx.BufferedUnsent()
|
||||
if buffered == 0 && h.closing {
|
||||
// If Close called and no more data to be sent, terminate connection!
|
||||
h.closing = false
|
||||
@@ -328,6 +328,15 @@ func (h *Handler) BufferedInput() int {
|
||||
return h.bufRx.Buffered()
|
||||
}
|
||||
|
||||
// BufferedUnsent returns the number of bytes in the socket's transmit(output) buffer
|
||||
// that has yet to be sent.
|
||||
func (h *Handler) BufferedUnsent() int {
|
||||
if h.State().IsClosed() {
|
||||
return 0
|
||||
}
|
||||
return h.bufTx.BufferedUnsent()
|
||||
}
|
||||
|
||||
// AvailableOutput returns amount of bytes available to write to output
|
||||
// before [Handler.Write] returns an error.
|
||||
func (h *Handler) AvailableOutput() int {
|
||||
|
||||
Reference in New Issue
Block a user