Also, you might find something like nats.io simplifies you’re effort. I’m not sure if it supports extremely large message sizes off hand, but there is probably a chunking layer available. Doing simple TCP messaging is fairly easy, when you get into redundancy, fan-out, etc is can get complex fast, so using a messaging library may help.
> On Dec 31, 2019, at 10:37 AM, Robert Engels <reng...@ix.netcom.com> wrote: > > > All of the source is there... but in general it is a bit more complex under > the covers than most - as it uses select/poll to know when a socket is ready > for IO then schedules the routine in the Read() to perform the IO. So Go has > a bit of its own kernel code than you would see in typical synchronous C > socket code. Ultimately Read() becomes a standard read() on the socket > descriptor. > >>> On Dec 31, 2019, at 10:03 AM, Ron Wahler <ron.wah...@gmail.com> wrote: >>> >> >> \\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. -- 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/113814DD-0320-4B19-ADB4-21E6ECF553BC%40ix.netcom.com.