From eb32fe20c8513b936faf908985d021caa87d5b0d Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 17 Sep 2014 15:57:32 +0200 Subject: [PATCH] Rewrite --- ethwire/messaging.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ethwire/messaging.go b/ethwire/messaging.go index 2161ce27fd..b1cefc0ae8 100644 --- a/ethwire/messaging.go +++ b/ethwire/messaging.go @@ -96,7 +96,7 @@ func ReadMessages(conn net.Conn) (msgs []*Msg, err error) { for { // 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 b := make([]byte, 1440) n, _ := conn.Read(b) @@ -110,6 +110,9 @@ func ReadMessages(conn net.Conn) (msgs []*Msg, err error) { } if n == 0 && len(buff) == 0 { + // If there's nothing on the wire wait for a bit + time.Sleep(200) + continue }