* Handle TCP end (FIN from remote) from main thread * @private
(msg)
| 210 | let written = 0; |
| 211 | while (written < length) { |
| 212 | const chunk = this.txChunks[0]; |
| 213 | const count = Math.min(chunk.length - this.txOffset, length - written); |
| 214 | chunk.copy(result, written, this.txOffset, this.txOffset + count); |
| 215 | written += count; |
| 216 | this.txOffset += count; |
| 217 | if (this.txOffset === chunk.length) { |
| 218 | this.txChunks.shift(); |
| 219 | this.txOffset = 0; |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | this.txBytes -= length; |
| 224 | |
| 225 | // Reading from the frame pipe creates room for pending TCP data. Pump |
| 226 | // all flows here so host sockets resume without waiting for an |
| 227 | // unrelated ACK or host event. |
| 228 | if (this.txBytes < NIC_TX_HIGH_WATER) this._pumpTcpFlows(); |
| 229 | return result; |
| 230 | } |
no test coverage detected