Code Monkey home page Code Monkey logo

Comments (6)

tonywok avatar tonywok commented on August 30, 2024

I am also getting this. Is this the intended behavior?

Is this library still being maintained?

from objc-zmq.

rmcgibbo avatar rmcgibbo commented on August 30, 2024

I had to switch the code to using 0MQ 2 instead of but here's a fix for the nonblocking issue:

If I have time later, I'll package this all up as a PR

Basically, you just need to check for errno=EAGAIN per http://api.zeromq.org/2-1:zmq-recv

#pragma mark Communication
- (NSData *) recv:(ZMQMessageReceiveFlags) flags {
    zmq_msg_t data;
    int err = zmq_msg_init(&data);
    if (err) {
        ZMQLogError(self, @"zmq_msg_init");
        return nil;
    }

    errno = 0;
    err = zmq_recv(self.socket, &data, flags);
    if (err) {
        if (flags == ZMQ_NOBLOCK && errno == EAGAIN) {
            zmq_msg_close(&data);
            return nil;
        } else {
            ZMQLogError(self, @"zmq_recv");
            err = zmq_msg_close(&data);
            if (err) {
                ZMQLogError(self, @"zmq_msg_close");
            }
        }
    }

    size_t length = zmq_msg_size(&data);
    NSData *msg = [NSData dataWithBytes:zmq_msg_data(&data) length:length];

    err = zmq_msg_close(&data);
    if (err) {
        ZMQLogError(self, @"zmq_msg_close");
        /* fall through */
    }
    return msg;
}

from objc-zmq.

rmcgibbo avatar rmcgibbo commented on August 30, 2024

I just learned objective-c today, but fortunately this library is pretty simple, if poorly documented.

from objc-zmq.

runningdemo avatar runningdemo commented on August 30, 2024

@rmcgibbo you save my day. Thank you.

from objc-zmq.

runningdemo avatar runningdemo commented on August 30, 2024

@rmcgibbo not working when receive data from server

<ZMQSocket: 0x9155cc0 (ctx=0x9153da0, type=ZMQ_XREQ, endpoint=tcp://10.8.8.18:12345, closed=0)>: zmq_recv: Undefined error: 0

from objc-zmq.

jeremy-w avatar jeremy-w commented on August 30, 2024

Contributions are welcome.

from objc-zmq.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.