Code Monkey home page Code Monkey logo

objc-zmq's Introduction

objc-zmq

objc-zmq is an Objective-C binding to ZeroMQ

This is an Objective-C version of the reference ZeroMQ [object-oriented C API][zmq-docs]. It follows the guidelines laid out by the official ["Guidelines for ZeroMQ bindings"][binding-zmq].

[zmq-docs]: http://api.zeromq.org/zmq.html (zmq(7) Manual Page) [binding-zmq]: http://www.zeromq.org/docs:bindings (Guidelines for ZeroMQ Bindings)

Usage

To run the example project; clone the repo, and run pod install from the Project directory first.

Requirements

  • OSX 10.9 (Mavericks)
  • Xcode 5.0.2

Installation

objc-zmq is not yet available through CocoaPods.

To install it simply add the following line to your Podfile:

pod "objc-zmq", :git => 'https://github.com/jeremy-w/objc-zmq.git'

License

objc-zmq is available under the MIT license. See the LICENSE file for more info.

Documentation

Refer to the [ZeroMQ manual pages][zmq-docs].

The Objective-C binding maintains a bit more state than the C API exposes, in that you can query a ZMQContext for its sockets and query a ZMQSocket for its context.

Thread Safety

Early versions of ZeroMQ had some restrictive thread safety and coupling issues:

  • Sockets can only be used from the thread that created them.
  • All ZMQ sockets provided in a single call to zmq_poll() must have been created using the same context.

Because sockets are coupled to contexts for polling, you have to track each socket's context and make sure not to mix them. (The ZMQSocket class tracks this for you.) This is not as restrictive as it sounds, because most applications will only ever use a single context.

Prior to version 2.1.0, each socket was permanently bound to the thread that created it. This made it very difficult to use ZeroMQ sockets with Grand Central Dispatch or NSOperationQueue, because the only persistent thread that these two APIs expose is the thread you're least likely to want to perform socket operations on: the main thread.

Starting with version 2.1.0, a socket can be used from different threads provided a full memory barrier, such as that introduced by <libkern/OSAtomic.h>'s OSMemoryBarrier function, separates the socket's use on one thread from its use on another.

To Do

  • Add functional tests in the form of sample code.
  • Tie polling into the runloop, similar to NSStream, CFSocket, or CFFileDescriptor.

objc-zmq's People

Contributors

alper avatar calvinchengx avatar clarete avatar codingguy avatar ecoffey avatar jeremy-w avatar neoneye avatar rowanj avatar szehnder avatar technolize avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

objc-zmq's Issues

ZMQException on setting ZMQ_CURVE_SECRETKEY value on a ZMQSocket

Hi,

I'm trying to implement the CURVE authentification using objc-zmq, and when I try to sent any of the ZMQ_CURVE_* options on a socket I get this exception:

Terminating app due to uncaught exception 'ZMQException', reason: 'No such process'

Is CURVE supported? is using the - (BOOL)setData:(NSData *)data forOption:(ZMQSocketOption)option the right function call to set this kind of data?

Any help is appreciated!

objc-zmq background, flash back

I start ZMQ, then ios device lock screen, flash back, error is as follows:

  1. When the lock screen, appear inkpad output:
    Bad file descriptor (tcp_connecter.cpp:301)
  2. When the screen to unlock, appear the following error:
    Gymne_YDD_iPhone`zmq::zmq_abort:
    0x100451454 <+0>: stp x29, x30, [sp, #-16]!
    0x100451458 <+4>: mov x29, sp
    0x10045145c <+8>: bl 0x10057c4b4 ; symbol stub for: abort

Could you tell me how to solve this problem?Very grateful!

How does this work?

There is no source code of Zero MQ within this package ?
I was able to create the .a file with your script or within Xcode, and now? Where are the functions connect, bind, send, recve?

Non blocking read triggers log message

If you do a non blocking read:

id data = [socket receiveDataWithFlags:ZMQ_NOBLOCK];

and there's nothing on the queue, you get the log message:

zmq_recv: Resource temporarily unavailable

Perhaps it should check for the ZMQ_NOBLOCK flag?

How to use it for iphone

i can't built it for iphone-os,can you help me?
xcode give me a Warning:
ld: warning: in /Users/username/Projects/ProjTest/SuperDemo/Trunk/Test2/libzmq.a, file was built for unsupported file format which is not the architecture being linked (i386)

Thanks

Build universal

Is the build_universal.sh script to build obj-zmg or zeromq into a fat library? And why does it only have x86 architectures and no arm in it?

Unable to send request to server

Currently, I'm trying to get the lib working in my project, but with no results. I copied its source classes and objective-c wrapper classes (ZMQContext, ZMQSocket) to my project and was able to build it successfully. However, I'm getting "resource temporary is unavailable" when trying to send a request to a server. Here's my code:

ZMQContext *context = [[ZMQContext alloc] initWithIOThreads:1];
ZMQSocket *socket =[context socketWithType:ZMQ_REQ];
BOOL success = [socket connectToEndpoint:@"tcp://X.X.X.X:X"];

if (success){
NSLog(@"connected to server");
}

NSData *data = [self RequestData];

success = [socket sendData:data withFlags:0];

if (success){
NSLog(@"Data sent to server");
}
Somehow, "connectToEndpoint" call is successful, however i can't' say the same about send. I can assure the host is reachable via the port, because server side socket communication version is already in production state. What I'm doing wrong?

Compilation for iOS.

When I try to compile this for iOS I get a ton of link errors. Are there any extra steps I have to take to get this to work?

objc-zmq issues using Xcode 10

Hi , I have used your pod in correct way with xcode 9.4 but when i made an update to Xcode 10 , I have many issue for the project's architecture ( arm64) : I have tried many solutions + Now I force my project to be compiled by adding libstdc-.6.0.9.tbd file in my xcode lib directory (temorary solution) and i can't run my project on device since references to libstdc++ (including -lstdc++, -lstdc++.6.0.9, libstdc++.6.0.9.tbd, and libstdc++.6.0.9.dylib) were removed on Xcode 10 : -lstdc++ was removed from Build Phases--> Link binary with librairies and adding such flag in other linker flags is obselete now.
Project dependencies such as static archives that were built against libstdc++ will also need to be rebuilt against libc++.
Apple will unlikely ever support libstdc++ again. So could you rebuild your archive against libC++ , i need this to make submission in the App Store.
Thanks.

Bundled project has DEPLOYMENT_TARGET of 10.9, but podspec targets 10.10+

Workaround: Edit the sample project Podfile to target 10.10 or later.


I get the following errors when I try to run the sample project:

Scotts-MBP:objc-zmq slcott$ cd Project/
Scotts-MBP:Project slcott$ pod install
Updating local specs repositories

CocoaPods 1.0.0.beta.8 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.

Analyzing dependencies
Fetching podspec for `objc-zmq` from `../objc-zmq.podspec`
[!] Unable to satisfy the following requirements:

- `objc-zmq (from `../objc-zmq.podspec`)` required by `Podfile`
- `objc-zmq (from `../objc-zmq.podspec`)` required by `Podfile`
- `objc-zmq (from `../objc-zmq.podspec`)` required by `Podfile`
- `objc-zmq (from `../objc-zmq.podspec`)` required by `Podfile`
- `objc-zmq (from `../objc-zmq.podspec`)` required by `Podfile`

Specs satisfying the `objc-zmq (from `../objc-zmq.podspec`)` dependency were found, but they required a higher minimum deployment target.

Specs satisfying the `objc-zmq (from `../objc-zmq.podspec`)` dependency were found, but they required a higher minimum deployment target.

Specs satisfying the `objc-zmq (from `../objc-zmq.podspec`)` dependency were found, but they required a higher minimum deployment target.

Specs satisfying the `objc-zmq (from `../objc-zmq.podspec`)` dependency were found, but they required a higher minimum deployment target.

Specs satisfying the `objc-zmq (from `../objc-zmq.podspec`)` dependency were found, but they required a higher minimum deployment target.

linker error when we use armv7 in zeromq

I followed this blog http://paolodenti.blog.com/2012/07/24/zeromq-ios and create a framework. The framework is successfully build when I include framework in my project and user armv 7, I get 20 error if I used armv6 it successfully build.

Undefined symbols for architecture armv7:
"_zmq_msg_init_size", referenced from:
-[ZMQSocket sendData:withFlags:] in ZMQSocket.o
"_zmq_recvmsg", referenced from:
-[ZMQSocket receiveDataWithFlags:] in ZMQSocket.o
"_zmq_msg_size", referenced from:
-[ZMQSocket sendData:withFlags:] in ZMQSocket.o
-[ZMQSocket receiveDataWithFlags:] in ZMQSocket.o
"_zmq_msg_close", referenced from:
-[ZMQSocket sendData:withFlags:] in ZMQSocket.o
-[ZMQSocket receiveDataWithFlags:] in ZMQSocket.o
"_zmq_msg_data", referenced from:
-[ZMQSocket sendData:withFlags:] in ZMQSocket.o
-[ZMQSocket receiveDataWithFlags:] in ZMQSocket.o
"_zmq_connect", referenced from:
-[ZMQSocket connectToEndpoint:] in ZMQSocket.o
"_zmq_msg_init", referenced from:
-[ZMQSocket receiveDataWithFlags:] in ZMQSocket.o
"_zmq_errno", referenced from:
-[ZMQContext initWithIOThreads:] in ZMQContext.o
-[ZMQSocket initWithContext:type:] in ZMQSocket.o
-[ZMQSocket close] in ZMQSocket.o
-[ZMQSocket setData:forOption:] in ZMQSocket.o
-[ZMQSocket dataForOption:] in ZMQSocket.o
-[ZMQSocket bindToEndpoint:] in ZMQSocket.o
-[ZMQSocket connectToEndpoint:] in ZMQSocket.o
...
"_zmq_socket", referenced from:
-[ZMQSocket initWithContext:type:] in ZMQSocket.o
"_zmq_sendmsg", referenced from:
-[ZMQSocket sendData:withFlags:] in ZMQSocket.o
"_zmq_setsockopt", referenced from:
-[ZMQSocket setData:forOption:] in ZMQSocket.o
"_zmq_bind", referenced from:
-[ZMQSocket bindToEndpoint:] in ZMQSocket.o
"_zmq_strerror", referenced from:
-[ZMQContext initWithIOThreads:] in ZMQContext.o
-[ZMQSocket initWithContext:type:] in ZMQSocket.o
-[ZMQSocket close] in ZMQSocket.o
-[ZMQSocket setData:forOption:] in ZMQSocket.o
-[ZMQSocket dataForOption:] in ZMQSocket.o
-[ZMQSocket bindToEndpoint:] in ZMQSocket.o
-[ZMQSocket connectToEndpoint:] in ZMQSocket.o
...
"_zmq_close", referenced from:
-[ZMQSocket close] in ZMQSocket.o
"_zmq_term", referenced from:
-[ZMQContext terminate] in ZMQContext.o
"_zmq_init", referenced from:
-[ZMQContext initWithIOThreads:] in ZMQContext.o
"_zmq_poll", referenced from:
+[ZMQContext pollWithItems:count:timeoutAfterUsec:] in ZMQContext.o
"_zmq_getsockopt", referenced from:
-[ZMQSocket dataForOption:] in ZMQSocket.o
"_zmq_version", referenced from:
+[ZMQContext getZMQVersionMajor:minor:patch:] in ZMQContext.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

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.