into that buffer, if it is equal to the length of the buffer, double the
buffer on the next read, if it is less than 1/2, halve the buffer. You may
want to read the other thread in this discussion about a proposal for a
concurrent version of io.Copy.
On Sunday, 1 February 2015 06:13:06 UTC+11, Matt Harden wrote:
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 <hawk_...@miiicasa.com <javascript:>>
wrote:
--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 <hawk_...@miiicasa.com <javascript:>>
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...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/d/optout.
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...@googlegroups.com <javascript:>.
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.