4 Commits
Author SHA1 Message Date
xtaci 3b95be5bc9 fix a test 2026-01-26 21:15:53 +08:00
xtaci c55575ea34 feat: autocleanup when both sides called CloseWrite() 2026-01-26 20:47:46 +08:00
xtaci baf236b97a feat(stream): implement TCP half-close support via CloseWrite()
Add CloseWrite() method to enable TCP-like half-close semantics without
protocol changes. This allows one side to signal EOF while still receiving
data from the peer.

Changes:
- Add chWriteClosed channel to track local write-side closure
- Add CloseWrite() method that sends FIN but keeps read side open
- Modify writeV1/writeV2 to check local write state instead of remote FIN
- Update Close() to also close write side for backward compatibility

The existing cmdFIN protocol command is reused - CloseWrite sends FIN to
signal write completion while the stream remains readable.

Usage:
  stream.Write(data)
  stream.CloseWrite()  // send FIN, can still read
  io.ReadAll(stream)   // read peer's response
2026-01-26 18:20:43 +08:00
xtaci 4af4b02304 use bufferRing in stream.go to reduce memory allocations 2026-01-26 15:17:20 +08:00