[zeromq-dev] Assertion failed: Address already in use
Matthias Kluwe
mkluwe at gmail.com
Tue Jun 3 22:40:32 CEST 2014
Hi!
I'm experiencing an unexpected error when using and tearing down a ZMQ
context in a rapid sequence. I tried this with Windows XP using ZeroMQ 4.04.
Test code is as follows (using a "fresh" REQ-REP connection once in a loop):
#include "zmq.h"
#include <string.h>
int c_send_receive() {
char buf[ 4 ];
void *ctx = zmq_ctx_new();
if ( ctx == 0 ) return 0;
void *rep = zmq_socket( ctx, ZMQ_REP );
if ( rep == 0 ) return 0;
if ( zmq_bind( rep, "tcp://*:5555" ) == -1 ) return 0;
void *req = zmq_socket( ctx, ZMQ_REQ );
if ( req == 0 ) return 0;
if ( zmq_connect( req, "tcp://localhost:5555" ) == -1 )
return 1;
if ( zmq_send( req, "MSG", 3, 0 ) == -1 ) return 0;
memset( buf, 0, 4 );
if ( zmq_recv( rep, buf, 3, 0 ) == -1 ) return 0;
if ( strcmp( "MSG", buf ) != 0 ) return 0;
if ( zmq_close( rep ) == -1 ) return 0;
if ( zmq_close( req ) == -1 ) return 0;
if ( zmq_ctx_term( ctx ) == -1 ) return 0;
return 1;
}
int main() {
while ( c_send_receive() );
}
The code above tries to check for all error code (hopefully), but it
fails throwing the following exception:
Assertion failed: Address already in use
(..\..\..\src\tcp_connecter.cpp:284)
I guess this is due to ZeroMQ encountering some unexpected condition.
Regards,
Matthias
More information about the zeromq-dev
mailing list