[zeromq-dev] ZMQ 2.0.6 connect SUB socket error

Matthew Giedt mgiedt at gmail.com
Wed Mar 17 17:12:50 CET 2010


Hello --

I just upgraded from 2.0b2 to 2.0.6 -- (downloaded, ./configure --> make -->
make install, verified new libraries and include)

When running the following program with:

./test tcp://lo:5551 tcp://localhost:5551 data.txt

 I get:

publishing on: tcp://lo:5551 success.
subscribing on: tcp://localhost:5551
terminate called after throwing instance of zmq::error_t
  what():  Invalid argument
Aborted

Are you guys seeing the same thing? Is it an upgrade from previous beta
issue?

With thanks,
-Matt

----------------------------------------------------------------------------

#include <iostream>
#include <fstream>
#include <string>

#include <zmq.hpp>

using namespace std;

int main( int argc, char *argv[] )
{
    string line;
    zmq::message_t msg;
    zmq::context_t ctx ( 1, 1 );
    zmq::socket_t pub ( ctx, ZMQ_PUB );
    zmq::socket_t sub ( ctx, ZMQ_SUB );

    cout << "publishing on: " << argv[ 1 ];
    pub.bind( argv[ 1 ] );
    cout << " success." << endl;

    cout << "subscribing on: " << argv[ 2 ];
    sub.connect( argv[ 2 ] );
    cout << " success." << endl;

    cout << "opening file: " << argv[ 3 ] << endl;
    ifstream xmlfile ( argv[ 3 ] );

    if( xmlfile.is_open() )
    {
        while(! xmlfile.eof() )
        {
            getline( xmlfile, line );

            cout << " <-- " << line << endl;

            const char* xml = line.c_str();
            const int len = strlen( xml ) + 1;

            msg.rebuild ( len );
            memcpy( msg.data(), xml, len );

            pub.send( msg );
            sub.recv( &msg );

            cout << " --> " << (char *)msg.data() << endl;

            sleep( 1 );
        }
    }

    xmlfile.close();
    return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20100317/73f501e1/attachment.htm>


More information about the zeromq-dev mailing list