ZeroMQ

Hello!

Has anyone attempted, or succeeded, in porting the ZeroMQ library to Xojo? Or wrapped the library in Xojo objects?

Thanks!
Mark

[quote=317457:@Mark Lubratt]Hello!

Has anyone attempted, or succeeded, in porting the ZeroMQ library to Xojo? Or wrapped the library in Xojo objects?

Thanks!
Mark[/quote]

what is ZeroMQ?

This http://zeromq.org ?

ages ago (literally you’d have to buy the xDev back issues from a long time ago) I wrote an article implementing a STOMP client for Apache ActiveMQ (see http://www.xdevmag.com/browse/6.3/6310/)
Different archiecture that has different pro’s / cons than Zero
One I liked was guaranteed delivery even if clients went offline and eventually came back online

IANAL BUT since you cant statically link it into your app (like you might with a C/C++ based app) I would expect you could run into issues with the LGPL license

An Apache’s license is much more liberal

I am also interested in zeroMQ with Xojo. Im not a license GURU but the ZeroMQ License page states that there is a ‘static link exception’ that may address Norm Palardy’s concern. See http://zeromq.org/area:licensing which states:

  • ZeroMQ is safe for use in close-source applications. The LGPL share-alike terms do not apply to applications built on top of ZeroMQ.

  • You do not need a commercial license. The LGPL applies to ZeroMQ’s own source code, not your applications. Many commercial applications use ZeroMQ.

  • Static linking exception. The copyright holders give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you must extend this exception to your version of the library.

IANAL and its ambiguous to me whether that would qualify for the exemption or not
You might be able to create a plugin that has statically linked zeromq in
But then the thing you’ve included is NOT statically linked into your application - its still a dylib/dll
And anything that says “license” and “i’m not sure” means you should talk to a lawyer who specializes in this sort of thing
And that generally means “spend a bunch of money” to maybe avoid being sued

GPL / LGPL is, IMHO, unclear enough I tend to just avoid it and prefer BSD style licenses as they are much clearer

And the benefits of trying to get this running under a cooperative threaded environment would be what exactly???

If interested I can always offer to wrap such a library as a xojo plugin. Email me if interested.

1 Like

I agree with James that this would not produce the outcome you expect.

James, in my case… I have a requirement to consume ZeroMQ messages produced elsewhere.

I also agree with Norm P. re… check with lawyers.

Perhaps M. Lubratt or others would find this a useful path go down:
This afternoon I was able to get the simple zeroMQ ‘hello world’ sort of demo client to work using OSX with the following using Declares (tested against both the std C and python “hwserver” examples shipped with ZeroMQ running on the same macbook.

As Norman points out - this is using dylibs.

		// found these needed constants  in C libzmq  includes directory  file  zmq.h 
		Const ZMQ_REQ = 3
		Const ZMQ_REP = 4
		
		//this is where the default install placed the lib on OSX
		CONST dylibLocation ="/usr/local/lib/libzmq.dylib"
		
		
		Declare Function zmq_ctx_new Lib dylibLocation ( ) as Ptr
		Declare Function zmq_socket Lib dylibLocation (ctx as Ptr, type as Integer ) as Ptr
		Declare Sub zmq_connect Lib dylibLocation (requester as Ptr,  s as CString) 
		Declare Function zmq_send Lib dylibLocation (requester as Ptr,  s as CString, len as Integer, flags as Integer) as Integer
		Declare Function zmq_recv Lib dylibLocation (requester as Ptr,   s as Ptr, len as Integer, flags as Integer)  as Integer
		Declare Function zmq_close Lib dylibLocation (requester as Ptr ) as Integer
		Declare Function zmq_ctx_destroy Lib dylibLocation (ctx as Ptr ) as Integer
		
		// havent tried the server yet...
		//Declare Function zmq_bind Lib dylibLocation (s as Ptr, addr as Int8 ) as Integer
		
		Dim buffer as New MemoryBlock(10)
		
		Dim s as Cstring
		
		Dim retval, sz as integer
		
		
		Dim context as Ptr = zmq_ctx_new() 
		Dim requester As Ptr = zmq_socket(context, ZMQ_REQ)
		zmq_connect (requester, "tcp://localhost:5555")
		
		
		for i as integer = 0 to 5
				TextArea1.AppendText "Sent Hello"+EndOfLine
				retval = zmq_send (requester, "Hello", 5, 0)
				sz = zmq_recv (requester, buffer, 10, 0)
				TextArea1.AppendText "got size:" + CStr(sz)   +EndOfLine
				s = buffer
				TextArea1.AppendText "got" + s   + EndOfLine
		next i
		
		retval = zmq_close (requester)
		retval = zmq_ctx_destroy (context)