FAQ
If a Reader is not closed and there is no data available, Read will block
(wait) until some data is available. When data is available, Read returns
as many as it can that will fit in the buffer. Use a buffer large enough
and you will get all available bytes. No need to get the current amount of
available data before reading. I don't think it's possible either.
On Sat Jan 31 2015 at 9:41:07 AM wrote:

I am implementing a server to proxy arbitrary size data from one socket to
another. As long as data is available in socket , a go routine is
responsible to write out as efficient as possible. I would like to read all
data in socket and write all of data into another socket. But as I know,
golang's read function returns from either EOF, specific length or specific
char. Could I know how many available data in buffer? So that the buffer is
good to fit the reading data and write to socket at once. I thought this
method is the most efficient. Isn't it? Thanks for help.

--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 31, '15 at 3:40p
activeJan 31, '15 at 8:37p
posts3
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase