It appears buf is not changing for each iteration of the loop. The first 10 bytes of the server's response stays in the slice through each iteration of the loop.
I've tried using bufio package to wrap it but the problem remains the same.
Dave Cheney
unread,
Nov 15, 2012, 2:15:23 AM11/15/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Hunter F, golan...@googlegroups.com
You are ignoring the number of bytes returned from Read
"It returns the number of bytes read (0 <= n <= len(p)) [...]
Read conventionally returns what is available instead of waiting for more."
It seems as if your loop reads the first 10 bytes properly and then reads
only 0 bytes (thus not changing buf). Check the number of bytes read
and print only those.
Volker
DisposaBoy
unread,
Nov 15, 2012, 2:33:51 AM11/15/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
two issues. one has already been given: you should not ignore the n return which tells you how much data was actually read. and the source of your infinite old data is that you're only doing one read. that is the pre-condition read . after that the pre-condition is never executed again and you there have an infinite loop on a variable that never changes
Ethan Burns
unread,
Nov 15, 2012, 8:09:40 AM11/15/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
This for loop does one read, then loops as long as err == nil; it never reads again.