[Lazarus] ZeroMQ Bindings
silvioprog
silvioprog at gmail.com
Tue Aug 23 18:40:13 CEST 2016
On Tue, Aug 23, 2016 at 1:26 PM, silvioprog <silvioprog at gmail.com> wrote:
> On Tue, Aug 23, 2016 at 1:15 PM, silvioprog <silvioprog at gmail.com> wrote:
>
>> On Tue, Aug 23, 2016 at 1:07 PM, Sandro Cumerlato <
>> sandro.cumerlato at gmail.com> wrote:
>>
>>> Maybe other side is not written in Free Pascal, I guess.
>>>
>>
>> Indeed.
>>
>>
>>> BTW: I got ZeroMQ TCP working (look at the attachments), IPC not yet :-(
>>
>>
>> I'm going to try it here with TEncoding, just a moment ...
>>
>
> Done. Please check the attached file: first, compile and run the myserver,
> after, compile and run the myclient. When you run the client it will print
> '0' and server will print a lot of 'hello world' message in the terminal. I
> noticed it creates a socket called 'localscp'.
>
> I'm not sure about zmq because it is very new for me.
>
A possible way to print the 'hello world' message for each client.
=== begin code ===
const
BUF_SIZE = 1024 * 1000;
var
context: pointer;
responder: pointer;
buf: TBytes;
recv: Integer;
begin
while True do
begin
context := zmq_ctx_new;
responder := zmq_socket(context, ZMQ_REP);
zmq_bind(responder, 'ipc://localscp');
SetLength(buf, BUF_SIZE);
while True do
begin
recv := zmq_recv(responder, buf[0], BUF_SIZE, 0);
if recv < 1 then
Break;
if recv > BUF_SIZE then
SetLength(buf, recv);
end;
WriteLn(TEncoding.UTF8.GetString(buf));
end;
end
=== end code ===
Sorry for the weird code, it is just a test, I would need time to read and
understand zmq.
--
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160823/35c42a97/attachment-0001.html>
More information about the Lazarus
mailing list