1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-05-25 21:49:09 -04:00

Apply buffered reader and writer to socks

This commit is contained in:
v2ray
2016-02-27 11:02:42 +01:00
parent cba26dabe8
commit ef51c600fb
4 changed files with 39 additions and 40 deletions

View File

@@ -26,7 +26,7 @@ func (this *BufferedWriter) Write(b []byte) (int, error) {
}
nBytes, _ := this.buffer.Write(b)
if this.buffer.IsFull() {
err := this.flush()
err := this.Flush()
if err != nil {
return nBytes, err
}
@@ -34,7 +34,7 @@ func (this *BufferedWriter) Write(b []byte) (int, error) {
return nBytes, nil
}
func (this *BufferedWriter) flush() error {
func (this *BufferedWriter) Flush() error {
nBytes, err := this.writer.Write(this.buffer.Value)
this.buffer.SliceFrom(nBytes)
if !this.buffer.IsEmpty() {
@@ -54,7 +54,7 @@ func (this *BufferedWriter) Cached() bool {
func (this *BufferedWriter) SetCached(cached bool) {
this.cached = cached
if !cached && !this.buffer.IsEmpty() {
this.flush()
this.Flush()
}
}