On 15/12/12 16:28, Claudio Carbone wrote:
Exact failing point is in socket_base.cpp at line 323:
/ rc = parse_uri (addr_, protocol, address);
if (rc != 0)
return -1;/
Even if rc is effectively 0 (checked in GDB), the if (don't know why)
returns true.
I'm at a loss here...
My bad, it's not there, rather somewhere deeper down the flow.
Anyway I've attached my simple library if anyone is feeling particularly
altruistic and wants to help me.
Here is the main I'm using
#include <cstdlib>
#include <saetta.h>
using namespace std;
/*
*
*/
int main(int argc, char** argv) {
Saetta::Server *myserver=new Saetta::Server;
Saetta::Client *myclient=new Saetta::Client;
while(1){
myserver->worker();
myclient->worker();
}
return 0;
}
Claudio
/*
* File: saetta.cpp
* Author: erupter
*
* Created on December 14, 2012, 6:32 PM
*/
#include "saetta.h"
namespace Saetta {
Server::Server()
{
this->_zmq_context_ptr = zmq_init(1);
if (this->_zmq_context_ptr == NULL)
throw error_t ();
this->_zmq_socket_ptr = zmq_socket (this->_zmq_context_ptr, ZMQ_PUB);
if (this->_zmq_socket_ptr == NULL)
throw error_t ();
int rc = zmq_bind (this->_zmq_socket_ptr, "tcp://*.5555");
if (rc != 0)
throw error_t ();
this->_counter=0;
}
Server::~Server()
{
}
void Server::worker()
{
sprintf(this->_count,"%03d",this->_counter);
// Write two messages, each with an envelope and content
s_sendmore (this->_zmq_socket_ptr, "A");
s_sendmore (this->_zmq_socket_ptr, "We don't want to see this");
s_send (this->_zmq_socket_ptr, this->_count);
s_sendmore (this->_zmq_socket_ptr, "B");
s_sendmore (this->_zmq_socket_ptr, "We would like to see this");
s_send (this->_zmq_socket_ptr, this->_count);
this->_counter++;
}
Client::Client()
{
/*this->_zmq_context = new zmq::context_t(1);
this-> _zmq_socket = new zmq::socket_t(this->_zmq_context,ZMQ_SUB);
//zmq::context_t context(1);
//zmq::socket_t subscriber (context, ZMQ_SUB);
this->_zmq_socket.connect("tcp://localhost:5555");
this->_zmq_socket.setsockopt( ZMQ_SUBSCRIBE, "B", 1);*/
}
Client::~Client()
{
}
void Client::worker()
{
// Read envelope with address
std::string address = s_recv (this->_zmq_socket_ptr);
// Read message contents
std::string contents = s_recv (this->_zmq_socket_ptr);
std::string termination = s_recv (this->_zmq_socket_ptr);
std::cout << "[" << address << "] " << contents << " | Termination ["<< termination<<"]"<< std::endl;
}
}/*
* File: saetta.h
* Author: erupter
*
* Created on December 14, 2012, 6:32 PM
*/
#ifndef SAETTA_H
#define SAETTA_H
extern "C" {
#include <zmq.h>
#include <zhelpers.h>
}
#include <string>
#include <iostream>
namespace Saetta
{
class Server
{
public:
Server(void);
virtual ~Server();
void worker();
private:
void *_zmq_context_ptr;
void *_zmq_socket_ptr;
std::string _base_ip_address;
int _client_list[];
int _counter;
char _count[3];
};
class Client
{
public:
Client(void);
virtual ~Client();
void worker();
private:
void *_zmq_context_ptr;
void *_zmq_socket_ptr;
};
}
#endif /* SAETTA_H */
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev