Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ForwarderDevice and StreamerDevice not working as expected #143

Open
OJ opened this issue Aug 22, 2013 · 0 comments
Open

ForwarderDevice and StreamerDevice not working as expected #143

OJ opened this issue Aug 22, 2013 · 0 comments

Comments

@OJ
Copy link

OJ commented Aug 22, 2013

I've been looking to use these two devices in an application and I believe the current implementations are incorrect.

The ForwarderDevice is part of the PUB-SUB pattern, which means that the front-end should be a SUB socket and the back-end a PUB socket. This is correct as it currently stands. However, when setting up the ForwarderDevice the constructor currently calls Bind() on the front-end socket when I believe it should instead be calling Connect(), since a SUB socket should be reaching out to the publish source (not expecting the publish source to connect to it). Here's what it looks like now:

    public ForwarderDevice(ZmqContext context, string frontendBindAddr, string backendBindAddr)
        : this(context)
    {
        FrontendSetup.Bind(frontendBindAddr);
        BackendSetup.Bind(backendBindAddr);
    }

    public ForwarderDevice(ZmqContext context, string frontendBindAddr, string backendBindAddr, DeviceMode mode)
        : this(context, mode)
    {
        FrontendSetup.Bind(frontendBindAddr);
        BackendSetup.Bind(backendBindAddr);
    }

And this is what I believe it should look like instead:

    public ForwarderDevice(ZmqContext context, string frontendBindAddr, string backendBindAddr)
        : this(context)
    {
        FrontendSetup.Connect(frontendBindAddr);
        BackendSetup.Bind(backendBindAddr);
    }

    public ForwarderDevice(ZmqContext context, string frontendBindAddr, string backendBindAddr, DeviceMode mode)
        : this(context, mode)
    {
        FrontendSetup.Connect(frontendBindAddr);
        BackendSetup.Bind(backendBindAddr);
    }

The StreamerDevice suffers the same issue, but in the other direction. That is, the back-end should instead be calling Connect() instead of Bind().

Is this a bug, or is this my lack of understanding that's causing issues? I can see in very early versions of clrzmq that the ForwarderDevice actually had the correct semantics so I believe that this is a regression.

Thanks.

PS. I'd have already fixed it and submitted a pull request, but the way the tests are set up for the devices is bound heavily to both ends calling Bind(), resulting in threads assuming a certain order of processing. It's a pain in the ass to unravel in such a way that it makes it generic for all tests. A bit of refactoring is needed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant