I've attached a test case where it create two PAIR sockets and attempts to send
a message from socket to another over INPROC, however it never gets past that..

I always get "Resource temporarily unavailable" with rc == 8 and zmq_errno() == 
11.

Here's what I've tried to mitigate that issue thinking that it might be the case
where the I/O threads don't have enough time to connect and send the message
(which if it was the case, which is not, should be handled internally).

* I've added sleep(1) before zmq_sendmsg(). [no effect]
* Added sleep(1) between bind() and connect(). [no effect]
* Done both above. [no effect]
* Applied the above for TCP. [no effect]
* Applied all of the above for most socket types (e.g. REQ/REP, PUB/SUB,
PUSH/PULL). [no effect]

Notes:
This is done against HEAD of libzmq git repository.

Compile line: gcc -I/libzmq/include -L/libzmq/src/.libs pair.c -o pair -lzmq &&
LD_LIBRARY_PATH=/libzmq/src/.libs ./pair

Please investigate and/or advise.
-- 
Amr Ali
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <zmq.h>

void my_free(void* data, void* hint)
{
	free(data);
}

int
main()
{
	void* c = zmq_init(2);
	void* s1 = zmq_socket(c, ZMQ_PAIR);
	void* s2 = zmq_socket(c, ZMQ_PAIR);

	zmq_bind(s1, "inproc://test");
	zmq_connect(s2, "inproc://test");

	void* data = malloc(8);
	assert(data);
	memcpy(data, "testPAIR", 8);

	zmq_msg_t msg;
	int rc = zmq_msg_init_data(&msg, data, 8, my_free, NULL);
	assert(rc == 0);

	rc = zmq_sendmsg(s2, &msg, 0);

	if (rc)
		perror(zmq_strerror(zmq_errno()));

	zmq_msg_close(&msg);

	rc = zmq_msg_init(&msg);
	assert(rc == 0);

	assert(zmq_recvmsg(s1, &msg, 0) == 0);

	assert(zmq_close(s1) == 0);
	assert(zmq_close(s2) == 0);
	assert(zmq_term(c) == 0);
}

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to