[zeromq-dev] Assertion failed: Address already in use
Pieter Hintjens
ph at imatix.com
Tue Jun 3 22:42:55 CEST 2014
It's poor design to bind on the same port over and over like this.
There are timing dependent tear-downs that will hit. E.g. as long as
there's a pending connection, the bound address won't be free for new
binds.
On Tue, Jun 3, 2014 at 10:40 PM, Matthias Kluwe <mkluwe at gmail.com> wrote:
> 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
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
More information about the zeromq-dev
mailing list