[zeromq-dev] Can I use a zmq socket with the inproc transport under Windows XP?

Joshua Foster jhawk28 at gmail.com
Tue Mar 6 04:44:42 CET 2012


On 3/5/2012 10:18 PM, yy l wrote:
> Thank you very much!
> But it is not work in my test code, why? My code:
> // Inproc_test.cpp : ??????????????
> //
> #include "stdafx.h"
> #include <D:\zeromq-2.1.7\include\zmq.h>
>
> DWORD WINAPI worker_routine(  LPVOID lpParameter )
> {
>  int rc;
>  zmq_msg_t msg;
>  void *context = lpParameter;
>     void *receiver = zmq_socket (context, ZMQ_SUB);
>     zmq_connect (receiver, "inproc://workers");
>     while (1)
>  {
>   rc = zmq_msg_init(&msg);
>   rc = zmq_recv(receiver, &msg, 0);
>   printf("receive a msg: %s\n", zmq_msg_data(&msg));
>   zmq_msg_close(&msg);
>     }
>     return 0;
> }
> int _tmain(int argc, _TCHAR* argv[])
> {
>  void *context;
>  void *pub_server;
>     context = zmq_init (0);
>     pub_server = zmq_socket (context, ZMQ_PUB);
>     zmq_bind (pub_server, "inproc://workers");
>  int thread_nbr;
>  DWORD dwPubThreadId;
>     for (thread_nbr = 0; thread_nbr != 1; thread_nbr++) {
>   CreateThread(
>    NULL,              // default security attributes
>    0,                 // use default stack size
>    worker_routine,    // thread function
>    context,           // argument to thread function
>    0,                 // use default creation flags
> &dwPubThreadId);   // returns the thread identifier
>     }
>  Sleep(10000);
>  int rc;
>  zmq_msg_t msg;
>
>  int cnt = 10;
Not a C/C++ expert but it is most likely because you are not subscribing 
on you ZMQ_SUB socket. If the platform does not support the transport, 
it will throw an exception.

Joshua

>  while (cnt-- > 0)
>  {
>   rc = zmq_msg_init_size(&msg, strlen("hello world!")+1);
>   memcpy(zmq_msg_data (&msg), "hello world!", strlen("hello world!")+1);
>   rc = zmq_send(pub_server, &msg, 0);
>   Sleep(1000);
>  }
>
>     return 0;
> }
>
>
> 2012/3/6 Joshua Foster <jhawk28 at gmail.com <mailto:jhawk28 at gmail.com>>
>
>     Yes, inproc works on Windows. You can use inproc between threads.
>     The ipc transport does not work under Windows. ipc is between
>     processes. It is recommended to use tcp://127.0.0.1
>     <http://127.0.0.1/> between processes on Windows.
>
>     Joshua
>
>
>     On 3/5/2012 9:14 PM, yy l wrote:
>>     Hello ereryone!
>>     Can I use a zmq socket with the inproc transport under Windows XP?
>>     Thank you!
>>
>>
>>     _______________________________________________
>>     zeromq-dev mailing list
>>     zeromq-dev at lists.zeromq.org  <mailto:zeromq-dev at lists.zeromq.org>
>>     http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
>     _______________________________________________
>     zeromq-dev mailing list
>     zeromq-dev at lists.zeromq.org <mailto:zeromq-dev at lists.zeromq.org>
>     http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120305/c3708213/attachment.htm>


More information about the zeromq-dev mailing list