1. 程式人生 > >ZeroMQ介面函式之 :zmq_inproc – ØMQ 本地程序內(執行緒間)傳輸方式

ZeroMQ介面函式之 :zmq_inproc – ØMQ 本地程序內(執行緒間)傳輸方式

—————————————————————————————————————

zmq_inproc(7)   ØMQ Manual - ØMQ/4.2.0

Name

zmq_inproc – ØMQ 本地程序內(執行緒間)傳輸方式

Synopsis

程序內傳輸方式意味著在共享ZMQ context的執行緒間通過記憶體方式傳輸資料。
在使用inproc方式進行傳輸時,不需要使用I/O執行緒。所以呢,如果你使用ZMQ context進行程序內訊息傳送,你可以初始化這個context的I/O執行緒為0。參見zmq_init(3)獲得更多細節。

Addressing

一個ZMQ終結點包括transport://跟著一個address(例如:inproc://someaddress)。Transport指明瞭要使用的底層協議。address指明瞭要連線的傳輸地址。

對於程序內傳輸,傳輸方式是inproc,address的含義在下面進行定義。

  為一個socket分配一個地址

當使用zmq_bind()函式給一個socket分配一個本地地址的時候,終結點必須是一個任意的唯一字串,用來建立一個檔案。這個檔名必須是在與這個socket關聯的ZMQ context上是唯一的,而且長度不能大於256位元組。對於這個檔名的格式沒有任何限制。

  連線一個socket

當使用zmq_connect()函式連線一個使用inproc傳輸方式的socket端時,終結點必須是一個唯一表示一個檔名的字串,作為用來連線的檔名。這個檔名在被連線時,必須保證已經被相同context上的一個socket建立了。

Examples

  給一個socket分配一個本地地址

//  Assign the in-process name "#1"
rc = zmq_bind(socket, "inproc://#1");
assert (rc == 0);
//  Assign the in-process name "my-endpoint"
rc = zmq_bind(socket, "inproc://my-endpoint");
assert (rc == 0);

連線一個socket

//  Connect to the in-process name "#1"
rc = zmq_connect(socket, "
inproc://#1"); assert (rc == 0); // Connect to the in-process name "my-endpoint" rc = zmq_connect(socket, "inproc://my-endpoint"); assert (rc == 0);

See also

zmq_bind(3)  zmq_connect(3)  zmq_ipc(7)  zmq_tcp(7)  zmq_pgm(7)  zmq(7)

Authors

This ØMQ manual page was written by Pieter Hintjens <[email protected]>, Martin Sustrik <[email protected]> and Martin Lucina <[email protected]>.

Web site design and content is copyright (c) 2007-2012 iMatix Corporation. Contact us for professional support. Site content licensed under the Creative Commons Attribution-Share Alike 3.0 License. ØMQ is copyright (c) Copyright (c) 2007-2012 iMatix Corporation and Contributors. ØMQ is free software licensed under the LGPL. ØMQ, ZeroMQ, and 0MQ are trademarks of iMatix Corporation. Terms of Use — Privacy

Policy

翻譯:風波

mail : [email protected]