The standard read will early return as soon as some of read is satisfied and a 
subsequent block would occur (or timeout) - so you have to decide when you want 
to stop reading...

>> On Dec 27, 2019, at 9:48 PM, Robert Engels <reng...@ix.netcom.com> wrote:
> 
> You need a termination point. In the case of ReadString it is the line 
> terminator. For an arbitrary read it is either a length or EOF - or you can 
> read until the underlying socket has no more data but this is generally 
> useless unless you are doing higher level buffering and protocol parsing. 
> This latter mode is almost never needed in Go due to synchronous nature. 
> 
>>> On Dec 27, 2019, at 9:36 PM, Ron Wahler <ron.wah...@gmail.com> wrote:
>> 
>> I did look at ReadAll, but it won't return until it sees EOF.  I am trying 
>> to find something that would return when the standard read would return. I 
>> get the memory part and would manage that. Any other ideas ?
>> 
>> thanks,
>> Ron 
>> 
>>> On Friday, December 27, 2019 at 5:11:42 PM UTC-7, Ron Wahler wrote:
>>> I am looking for a net.conn standard read that would return a data buffer 
>>> the exact size of the read. I am trying to read an unknown amount of byte 
>>> data from the connection. With the read i am using I am required to 
>>> pre-allocate a buffer and pass that buffer to the read. I am looking for a 
>>> read that works more like  the ReadString , but is for a byte slice.
>>> 
>>> // I want something similar to this read that returns the read string into 
>>> the message string.
>>>  message, err := bufio.NewReader(ServerConn).ReadString('\n')
>>> 
>>>                 if ( err != nil ){
>>> 
>>>                         fmt.Println("RELAY: ERROR:  Reg Message read err:", 
>>> err)
>>> 
>>>                         return 
>>> 
>>>                 }
>>> 
>>> 
>>> 
>>> 
>>> 
>>> // had to preallocate a buffer, but I want a read to return me a buffer so 
>>> I don't have to guess how big to make it.
>>> 
>>>  buf := make([]byte, 1024*32)
>>> 
>>>  // READ FROM CLIENT
>>> 
>>>  nBytes, err := Csrc.Read(buf)
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Is this not possible, I have not seen any examples that would indicate that 
>>> there is a standard library that would do something like what I am looking 
>>> for.
>>> 
>>> 
>>> 
>>> thanks,
>>> 
>>> Ron
>>> 
>> 
>> -- 
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/8ca83343-399d-47ef-aee0-0e173946c980%40googlegroups.com.
> -- 
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/8F20C49C-7240-4E58-A25D-583BD0482115%40ix.netcom.com.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/26594CE8-822F-44A7-A9FC-D894EE6C8D16%40ix.netcom.com.

Reply via email to