............
def chunks(lst, n):
"Yield successive chunks from lst, where n is a list of possible sizes"
i = 0
while i < len(lst):
k = min(random.choice(n), len(lst) - i)
yield lst[i:i + k]
i += k
.............On Jun 29, 2021, at 10:25 AM, 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:
<prooff.png>
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/f82a73ad-164e-4af5-b183-9d4bf0b54911n%40googlegroups.com.
<prooff.png><proof2.png>
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:
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/466d016b-b90b-4505-b4a8-7e5fc62679b4n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/0f12076e-f325-4583-ba85-857084aec83dn%40googlegroups.com.
I thought that after getting the bytes, chunk the data, I need to have the io.writer back before send the chunked dataSo far I came up with this:...cmd.Stdin = connbuf := new(bytes.Buffer)cmd.Stdout = bufbizz := buf.Bytes()var i intfor {n := int(math.Min(float64(rand.Intn(len(bizz))), float64(len(bizz))))d := bizz[i : i+n]i += nz := bytes.NewBuffer(d)kk := io.Writer(z) //this line creates the errortime.Sleep(400 * time.Millisecond)kk = connif i >= len(bizz) {break}}.....cmd.Stderr = conncmd.Run()But know I get this error:conn.go:95:21: kk declared but not used
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/2aebe5af-a078-4165-bde3-e235845c3de1n%40googlegroups.com.