[zeromq-dev] IPv6 multicast RADIO/DISH

Jabrane Hamdi jabrane.hamdi at gmail.com
Mon May 7 14:59:46 CEST 2018


Hi Lionel,

Thank you for your feedback. I think that my real problem is Go and not the
network.
In fact, when i use python, the work is done. But with Go, i have the
problem. You find below the code complete :


//  File Transfer model #1
//
//  In which the server sends the entire file to the client in
//  large chunks with no attempt at flow control.

package main

import (
zmq "github.com/pebbe/zmq4"

"fmt"
"io"
"os"
//"runtime"
)

const (
CHUNK_SIZE = 250000
)

func client_thread(pipe chan<- string) {
context,_ := zmq.NewContext()
dealer, _ := context.NewSocket(zmq.DEALER)
dealer.Connect("tcp://127.0.0.1:6000")

dealer.Send("fetch", 0)
total := 0  //  Total bytes received
chunks := 0 //  Total chunks received

for {
frame, err := dealer.RecvBytes(0)
if err != nil {
break //  Shutting down, quit
}
chunks++
size := len(frame)
total += size
if size == 0 {
break //  Whole file received
}
}
fmt.Printf("%v chunks received, %v bytes\n", chunks, total)
pipe <- "OK"
}

//  The server thread reads the file from disk in chunks, and sends
//  each chunk to the client as a separate message. We only have one
//  test file, so open that once and then serve it out as needed:

func server_thread() {
file, err := os.Open("testdata_1G")
if err != nil {
panic(err)
}
context,_ := zmq.NewContext()
router, _ := context.NewSocket(zmq.ROUTER)
//  Default HWM is 1000, which will drop messages here
//  since we send more than 1,000 chunks of test data,
//  so set an infinite HWM as a simple, stupid solution:
router.SetRcvhwm(0)
router.SetSndhwm(0)
router.Bind("tcp://*:6000")
for {
//  First frame in each message is the sender identity
identity, err := router.Recv(0)
if err != nil {
break //  Shutting down, quit
}

//  Second frame is "fetch" command
command, _ := router.Recv(0)
if command != "fetch" {
panic("command != \"fetch\"")
}

chunk := make([]byte, CHUNK_SIZE)
for {
n, _ := io.ReadFull(file, chunk)
router.SendMessage(identity, chunk[:n])
if n == 0 {
break //  Always end with a zero-size frame
}
}
}
file.Close()
}

//  The main task starts the client and server threads; it's easier
//  to test this as a single process with threads, than as multiple
//  processes:

func main() {
pipe1 := make(chan string)
//  Start child threads
go server_thread()
go client_thread(pipe1)
//  Loop until client tells us it's done
<-pipe1
}

2018-05-07 14:47 GMT+02:00 Lionel Flandrin <lionel at svkt.org>:

> On Wed, May 02, 2018 at 07:33:36PM +0200, Lionel Flandrin wrote:
> > On Sun, Apr 29, 2018 at 08:45:20AM +0300, Doron Somech wrote:
> > > I can try and help regarding adding IPv6 to RADIO/DISH UDP protocol.
> > >
> > > I don't think it should very complicated. I can try and point to you
> to the
> > > places in the code that need to have the support.
> > >
> >
> > Since my PR for the IP parsing code has just been merged I'm going to
> > start working on the UDP code momentarily, first by replacing the
> > existing address parsing code with the new ip_resolver API and then
> > trying to add IPv6 support. Let me know if you have any remarks or
> > complaints.
> >
> > Also I'm on the IRC channel if you want something more interactive for
> > discussion.
>
> I've made a PR for my work in progress to add IPv6 UDP support,
> feedback very welcome:
>
> https://github.com/zeromq/libzmq/pull/3081
>
> In particular there's the raw socket code I'm not sure I understand
> completely (see my comments in the PR).
>
> --
> Lionel Flandrin
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180507/3a88f11b/attachment.htm>


More information about the zeromq-dev mailing list