FAQ
I've been having trouble wrapping my head around around a problem I've been
having with the standard net package.

I want to read n bytes at a time of a socket. In this case 10 bytes of a
socket to google's webserver.

Full code: http://play.golang.org/p/zAQsO1x9rW

Running that I get:
Read: [72 84 84 80 47 49 46 48 32 50]
Read: [72 84 84 80 47 49 46 48 32 50]
Read: [72 84 84 80 47 49 46 48 32 50]
Read: [72 84 84 80 47 49 46 48 32 50]
Read: [72 84 84 80 47 49 46 48 32 50]
Read: [72 84 84 80 47 49 46 48 32 50]
...
Continuing on forever.

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.

--

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 6 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 15, '12 at 7:10a
activeNov 15, '12 at 1:10p
posts6
users5
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase