I'm getting ready to submerge myself into coding python java c++ all of it
I could use some pointers as to methods and tips

On Tue, Jun 29, 2021, 6:27 AM LetGo <non3co...@gmail.com> wrote:

> I have a proxy written in python with some logic that I would like to
> implement in a golang tool of mine, but I don't really know how to do it.
> It splits the data sent via socket (stdout) in small chunks, with a delay
> between each other
>
> I have a variable which gets a random number from a list:
> ....
>  listbytes = [87, 88, 89, 90]
> ....
>
> I have also a function which splits in small chunk of bytes(n) the
> data(lst):
>
> ............
>
> 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
> .............
>
> Both things are executed this way:
> ...
> # get the data
>             data = s.recv(BUFFER_SIZE)
>
>             if s == s_src:
>                 d = LOCAL_DATA_HANDLER(data)
>                 for chunk in chunks(d, listbytes):
> #sleep 1.6 seconds before sending the next chunk of data
>                     time.sleep(1.6)
> #send the chunked data
>                     s_dst.send(bytes(chunk) )
> ...
>
>
> How do I implement *the same exact logic* illustrated here?
>
> func (nObj NetObject) RunClient(cmd string) {
>     // Try connection
>
>     for {
>         conn, err := net.Dial(nObj.Type, nObj.Service)
>         fmt.Print("connect")
> //        msg := "status"
>         if err != nil {
>             fmt.Println("fail")
>         }
>         if err == nil {
>             fmt.Println("ok")
> //            defer conn.Close()
>             defer conn.Close()
>             log.Println("Connected to", conn.RemoteAddr())
>             handleConn(conn, cmd)
>
>
>             //handleConn(conn, cmd)
>             fmt.Println("After handle")
>                     }
>         fmt.Println("Before sleep")
>         time.Sleep(5 * time.Second)
>     }
>
> }
> Can you help me please?
>

-- 
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/CA%2BpBPkbndf-tKkbkg_NA04SarTnCkt2w2NhqCgD0Q2s_-uAs6w%40mail.gmail.com.

Reply via email to