mirror of
https://github.com/schollz/croc.git
synced 2024-11-24 08:02:33 +03:00
parent
386f4ff958
commit
9c0bc3efc3
@ -72,6 +72,9 @@ func (c *Comm) Write(b []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Comm) Read() (buf []byte, numBytes int, bs []byte, err error) {
|
func (c *Comm) Read() (buf []byte, numBytes int, bs []byte, err error) {
|
||||||
|
// long read deadline in case waiting for file
|
||||||
|
c.connection.SetReadDeadline(time.Now().Add(3 * time.Hour))
|
||||||
|
|
||||||
// read until we get 4 bytes for the header
|
// read until we get 4 bytes for the header
|
||||||
var header []byte
|
var header []byte
|
||||||
numBytes = 4
|
numBytes = 4
|
||||||
@ -102,6 +105,9 @@ func (c *Comm) Read() (buf []byte, numBytes int, bs []byte, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
buf = make([]byte, 0)
|
buf = make([]byte, 0)
|
||||||
|
|
||||||
|
// shorten the reading deadline in case getting weird data
|
||||||
|
c.connection.SetReadDeadline(time.Now().Add(10 * time.Second))
|
||||||
for {
|
for {
|
||||||
// log.Debugf("bytes: %d/%d", len(buf), numBytes)
|
// log.Debugf("bytes: %d/%d", len(buf), numBytes)
|
||||||
tmp := make([]byte, numBytes-len(buf))
|
tmp := make([]byte, numBytes-len(buf))
|
||||||
|
Loading…
Reference in New Issue
Block a user