Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions protocol/tcpsocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,23 @@ func TCPReadAmount(conn net.Conn, amount int) ([]byte, bool) {

return reply, true
}

// Read an amount and dont log errors if we fail to read from the socket
func TCPReadAmountBlind(conn net.Conn, amount int) ([]byte, bool) {
reply := make([]byte, amount)
totalRead := 0

// keep reading until we hit the desired amount (or an error occurs)
for totalRead < amount {
count, err := conn.Read(reply[totalRead:])
if err != nil {
return nil, false
}
if count == 0 {
return nil, false
}
totalRead += count
}

return reply, true
}
Loading