mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-26 05:17:19 +00:00
Rewrite
This commit is contained in:
parent
fd041d91ee
commit
eb32fe20c8
@ -96,7 +96,7 @@ func ReadMessages(conn net.Conn) (msgs []*Msg, err error) {
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
// Give buffering some time
|
// Give buffering some time
|
||||||
conn.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
|
conn.SetReadDeadline(time.Now().Add(5 * time.Millisecond))
|
||||||
// Create a new temporarily buffer
|
// Create a new temporarily buffer
|
||||||
b := make([]byte, 1440)
|
b := make([]byte, 1440)
|
||||||
n, _ := conn.Read(b)
|
n, _ := conn.Read(b)
|
||||||
@ -110,6 +110,9 @@ func ReadMessages(conn net.Conn) (msgs []*Msg, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if n == 0 && len(buff) == 0 {
|
if n == 0 && len(buff) == 0 {
|
||||||
|
// If there's nothing on the wire wait for a bit
|
||||||
|
time.Sleep(200)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user