Skip to content
Jiowcl edited this page Dec 29, 2021 · 2 revisions

Msg

Init Data Callback Function

' ZmqFreeFnProc
Sub ZmqFreeFnProc(Byval data_ As Any Ptr, Byval hint_ As Any Ptr)

End Sub

Msg Init

#Include "../Core/ZeroMQ.bi"

Dim lpszLibZmqDll As String = "libzmq.dll"

Dim hLibrary As Any Ptr = ZmqDllOpen(lpszLibZmqDll)

If hLibrary > 0 Then
    Dim vMsg As ZmqMsgT Ptr

    ZmqMsgInit(hLibrary, vMsg)
    ZmqMsgClose(hLibrary, vMsg)

    ZmqDllClose(hLibrary)
End If

Msg InitData

#Include "../Core/ZeroMQ.bi"

Dim lpszLibZmqDll As String = "libzmq.dll"

Dim hLibrary As Any Ptr = ZmqDllOpen(lpszLibZmqDll)

' ZmqFreeFnProc
Sub ZmqFreeFnProc(Byval data_ As Any Ptr, Byval hint_ As Any Ptr)

End Sub

If hLibrary > 0 Then
    Dim vMsg As ZmqMsgT Ptr
    Dim lpszMsg As String = "Hi There"
    Dim lMsgSize As Long = Len(lpszMsg)

    Dim tMsgPtr As ZString Ptr

    tMsgPtr = CAllocate(lMsgSize, SizeOfDefZStringPtr(tMsgPtr))
    *tMsgPtr = lpszMsg

    ZmqMsgInitData(hLibrary, vMsg, tMsgPtr, lMsgSize, @ZmqFreeFnProc, 0)
    ZmqMsgClose(hLibrary, vMsg)

    ZmqDllClose(hLibrary)
End If

Msg Init (ZMQ Wrapper)

#Include "../../Core/Enums.bi"
#Include "../../Core/ZeroMQWrapper.bi"

Dim lpszLibZmqDll As String = "libzmq.dll"

Dim hLibrary As Any Ptr = ZmqDllOpen(lpszLibZmqDll)

If hLibrary > 0 Then
    Dim vMsg As ZmqMsgT Ptr

    LibZmqMsg.Init(vMsg)
    LibZmqMsg.Close(vMsg)

    LibZMQWrapper.DllClose()
End If

Msg InitData (ZMQ Wrapper)

#Include "../../Core/Enums.bi"
#Include "../../Core/ZeroMQWrapper.bi"

Dim lpszLibZmqDll As String = "libzmq.dll"

Dim hLibrary As Any Ptr = ZmqDllOpen(lpszLibZmqDll)

If hLibrary > 0 Then
    Dim vMsg As ZmqMsgT Ptr

    Dim lpszMsg As String = "Hi There"
    Dim lMsgSize As Long = Len(lpszMsg)

    Dim tMsgPtr As ZString Ptr

    tMsgPtr = CAllocate(lMsgSize, SizeOfDefZStringPtr(tMsgPtr))
    *tMsgPtr = lpszMsg

    LibZmqMsg.InitData(vMsg, tMsgPtr, lMsgSize, @ZmqFreeFnProc, 0)
    LibZmqMsg.Close(vMsg)

    LibZMQWrapper.DllClose()
End If

Clone this wiki locally