"Socket operation on non-socket" - ZeroMQ socket in Go

Viewed 43

I'm trying to send messages using ZeroMQ from a program written in Go to another program written in Rust. The Rust side seems to be running fine, but the Go side does not send messages when the socket is called from inside a function.

I'm using the Pebbe zmq4 library and defining the sockets in a function that instantiates an object (not technically the constructor, but I may be wrong). Here is some of the code. The relevant parts are very spread out, so I'll only include the most important stuff.

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

func NewPod(...) *Pod {
...

    _derSock, err := zmq.NewSocket(zmq.PUSH)
    ...
    myPod := &Pod{
        ...
        derSock:     *derSock,
    }

    myPod.derSock.Connect("ipc:///tmp/router")
    _, err = myPod.derSock.Send("hi :)", 0)

}

If I send a message from inside that function, it works fine, but when I use the send function from inside a class method of MyPod, I get the error "socket operation on non-socket" I've seen that other people have similar problems, both with ZeroMQ and with normal sockets, but their problems are mostly in lower-level languages and the problems tend to be logic errors in the send call. However, the syntax that I use inside the class function is exactly the same as the call shown.

Creating sockets has worked fine before in the same part of this program, created the same way, when I used Unix domain sockets, but for some reason the switch to ZeroMQ isn't going as easily. I'm new to both of these languages and network programming, and this has stumped me for hours. Thanks in advance.

0 Answers
Related