ZeroMQ接口函數之 :zmq_inproc – ØMQ 本地進程內(線程間)傳輸方式


ZeroMQ API 目錄 :http://www.cnblogs.com/fengbohello/p/4230135.html

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

ZeroMQ 官方地址:http://api.zeromq.org/4-2:zmq-inproc

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 <ph@imatix.com>, Martin Sustrik <sustrik@250bpm.com> and Martin Lucina <mato@kotelna.sk>.

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 : fengbohello@qq.com

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM