\\One other note, if you have a request / response type protocol with 
fairly defined lengths, you don’t need a buffer larger than the largest 
message if you don’t allow concurrent requests from the same client. 

Yes, understood, that was not the constraint, I have to process an unknown 
amount of bytes, so I have been just trying to make sure I had the best 
solution.  

I would still like to read the underlying GoLang code on Read() to see what 
assumptions it makes to the system calls.

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/24a6f6bd-8948-434c-bb83-c663d75bb23d%40googlegroups.com.

Reply via email to