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

yy l liyongyan0523 at gmail.com
Tue Mar 6 04:18:20 CET 2012


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;
 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>

> 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 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 listzeromq-dev at lists.zeromq.orghttp://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/20120306/4f56e77b/attachment.htm>


More information about the zeromq-dev mailing list