-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from kondrenkov/master
Added testcase for #1588
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
#include <stdio.h> | ||
#include <assert.h> | ||
#include <unistd.h> | ||
|
||
#include <zmq.h> | ||
|
||
#define ENDPOINT "tcp://127.0.0.1:20000" | ||
#define FIRST_PART "this" | ||
#define FIRST_PART_LEN (sizeof(FIRST_PART) - 1) | ||
#define SECOND_PART "that" | ||
#define SECOND_PART_LEN (sizeof(SECOND_PART) - 1) | ||
#define SLEEP_TIME 1 | ||
|
||
|
||
int | ||
main() { | ||
int major, minor, patch, ret; | ||
void *ctx, *sender, *receiver; | ||
|
||
zmq_version(&major, &minor, &patch); | ||
printf("Current ØMQ version is %d.%d.%d\n", major, minor, patch); | ||
|
||
ctx = zmq_ctx_new(); | ||
assert(ctx); | ||
|
||
sender = zmq_socket(ctx, ZMQ_DEALER); | ||
assert(sender); | ||
|
||
receiver = zmq_socket(ctx, ZMQ_DEALER); | ||
assert(receiver); | ||
|
||
ret = zmq_bind(sender, ENDPOINT); | ||
assert(ret == 0); | ||
|
||
ret = zmq_connect(receiver, ENDPOINT); | ||
assert(ret == 0); | ||
|
||
sleep(SLEEP_TIME); | ||
|
||
// Send 1-st part of message | ||
ret = zmq_send(sender, FIRST_PART, FIRST_PART_LEN, ZMQ_SNDMORE | ZMQ_DONTWAIT); | ||
assert(ret == FIRST_PART_LEN); | ||
|
||
// Close the receiver | ||
ret = zmq_close(receiver); | ||
assert (ret == 0); | ||
sleep(SLEEP_TIME); | ||
|
||
// Tries to send 2-nd part... and possibly get Assertion failed: !more (lb.cpp:97) | ||
ret = zmq_send(sender, SECOND_PART, SECOND_PART_LEN, ZMQ_DONTWAIT); | ||
assert(ret == -1); | ||
|
||
zmq_close(sender); | ||
zmq_ctx_destroy(ctx); | ||
|
||
return 0; | ||
} |