No buffer space available (tcp.cpp:69) when setting SNDBUF and RCVBUF ZeroMQ, golang, MacOSX
<p>I have zeromq: stable 4.1.4 installed using brew on MacOSX and have written a simple PUB/SUB program to test zeromq.  But when I run the sample program using flags --bufsize > 5 (to use a buffer of size > 5MB) (go run go_zmq_pubsub.go --bufsize=6); it throws the following exception:</p>

<p>No buffer space available (tcp.cpp:69)
SIGABRT: abort
PC=0x7fff9911c286 m=0
signal arrived during cgo execution</p>

<p>Below is the program I used to test the zeromq4.x</p>

<pre><code>package main

import (
    "fmt"
    "flag"
    "strconv"
    "sync"
    log "github.com/Sirupsen/logrus"
    zmq "github.com/pebbe/zmq4"
    "time"
)

var _ = fmt.Println

func main(){
    var port int
    var bufsize int
    flag.IntVar(&amp;port, "port", 7676, "server's zmq tcp port")
    flag.IntVar(&amp;bufsize, "bufsize", 0, "socket kernel buffer size")

    flag.Parse();

    publisher, err := zmq.NewSocket(zmq.PUB)
    if(err != nil) {
        log.Fatal(err)
    }

    //set publisher kernel transmit buffer size
    //convert into bytes
    if err := publisher.SetSndbuf(bufsize * 1000000); err != nil {
        log.Fatal(err)
    }

    defer publisher.Close()
    publisher.Bind("tcp://*:" + strconv.Itoa(port))

    //SETUP subscriber
    subscriber, err := zmq.NewSocket(zmq.SUB)
    if(err != nil) {
        log.Fatal(err)
    }

    //set subscriber kernel receive buffer size
    if err := subscriber.SetRcvbuf(bufsize * 1000000); err != nil {
        log.Fatal(err)
    }

    defer subscriber.Close()
    subscriber.Connect("tcp://127.0.0.1:" + strconv.Itoa(port))
    subscriber.SetSubscribe("")

    var wg sync.WaitGroup
    wg.Add(2)

    idx := 0

    go func(wg *sync.WaitGroup) {
        //start streaming messages
        ticker := time.NewTicker(1 * time.Second)
        go func() {
            for {
                select {
                case &lt;-ticker.C:
                    _, err = publisher.Send("PKG:"+strconv.Itoa(idx), 0)

                    idx++;

                    if(err != nil) {
                        log.Error(err)
                    }
                }
            }
        }()
    }(&amp;wg)


    //receiver
    go func(wg *sync.WaitGroup) {
        go func(){
            for {
                payload, err := subscriber.Recv(0)
                _ = payload

                if err != nil {
                    log.Error(err)
                    break
                }

                //now sending into worker pool
                log.Info("RECEIVE:" + payload)
            }
        }()
    }(&amp;wg)

    wg.Wait()
}
</code></pre>

<p>On Centos7 with lib-zeromq built from source, the above code works without problem.</p>

<p>Not sure if it's due to libzeromq or the OS itself.</p>

<p>Thanks.</p>