I think I made some progress.... I think. Is it right what I'm doing ? ................ cmd.Stdin = conn // cmd.Stdout = conn // data := []byte(cmd.Stdout) data := cmd.Stdout var i int for { n := int(math.Min(float64(rand.Intn(len(data))), float64(len(data)))) d := data[i : i+n] i += n time.Sleep(400 * time.Millisecond) d = conn
if i >= len(data) { break } } cmd.Stderr = conn cmd.Run() ............................ But when I try to build I get these errors: conn.go:75:46: invalid argument data (type io.Writer) for len conn.go:76:16: cannot slice data (type io.Writer) conn.go:83:22: invalid argument data (type io.Writer) for len Il giorno martedì 29 giugno 2021 alle 19:37:04 UTC+2 LetGo ha scritto: > Thank you guys for all your answers and suggestions! > I really appreciate! > Sorry about the screenshots, it was the only way to make the packets > "human readable" > How could you code that kind of implementation based on your knowledge and > skill? > I have noone of these in golang ahah as I said, im too newbie to do all > this alone! > Also not working examples ( if they throw an error I don't care, based on > my code are fine! > These examples could rapresent a great start from me!(: > > > Il giorno martedì 29 giugno 2021 alle 19:00:06 UTC+2 > jesper.lou...@gmail.com ha scritto: > >> On Tue, Jun 29, 2021 at 5:24 PM LetGo <non3...@gmail.com> wrote: >> >>> Thanks for the answer! (: >>> In python it was straightforward to implement and it works like a charm. >>> It sends small packets with delay between each other without even care if >>> it is UDP or TCP: >>> >>> >> Beware! This is an assumption that will break at some point in time. >> Currently the delay and the OS makes things straightforward for you. But >> TCP doesn't behave like you expect, and you are very likely to run into >> trouble if the machine, the network, or the system starts taking additional >> load. >> >> You need to frame the data. A good way is to use 4 bytes as a size >> (unsigned 32 bit integer), followed by a payload of that size. You can then >> avoid this becoming an uncontrolled explosion in your software at a later >> date. You can also close connections early if too large messages get sent, >> etc. >> >> -- 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/2cc55906-5745-400f-83fa-d7ddc9259f3en%40googlegroups.com.