Commit 005ecca8 authored by legoc's avatar legoc
Browse files

Removed ContextZmq.createRequestSocket()

parent 08288c2a
......@@ -98,23 +98,4 @@ zmq::socket_t * ContextZmq::createCancelPublisher(const std::string& endpoint) {
return publisher;
}
zmq::socket_t * ContextZmq::createRequestSocket(const std::string& endpoint) {
zmq::socket_t* socket = new zmq::socket_t(*m_context.get(), ZMQ_REQ);
try {
// Set the linger value to 0 to ensure that pending requests are destroyed in case of timeout.
int value = 0;
socket->setsockopt(ZMQ_LINGER, &value, sizeof(int));
// Connect to the endpoint.
socket->connect(endpoint.c_str());
}
catch (exception const & e) {
throw SocketException(e.what());
}
return socket;
}
}
......@@ -45,7 +45,6 @@ public:
zmq::socket_t * createEventSubscriber(const std::string& endpoint, const std::string& cancelEndpoint);
zmq::socket_t * createOutputStreamSubscriber(const std::string& endpoint, const std::string& cancelEndpoint);
zmq::socket_t * createCancelPublisher(const std::string& endpoint);
zmq::socket_t * createRequestSocket(const std::string& endpoint);
private:
std::unique_ptr<zmq::context_t> m_context;
......
......@@ -16,6 +16,7 @@
#include "RequestSocketZmq.h"
#include "SocketException.h"
#include "ConnectionTimeout.h"
#include "ContextZmq.h"
#include <iostream>
......@@ -30,7 +31,6 @@ RequestSocketZmq::RequestSocketZmq(Context * context, const std::string& endpoin
m_context(dynamic_cast<ContextZmq *>(context)), m_endpoint(endpoint) {
init();
setTimeout(timeout);
}
......@@ -60,7 +60,21 @@ void RequestSocketZmq::init() {
// Reset if the socket is null.
if (m_socket.get() == nullptr) {
m_socket.reset(m_context->createRequestSocket(m_endpoint));
//m_socket.reset(m_context->createRequestSocket(m_endpoint));
m_socket = std::unique_ptr<zmq::socket_t>(new zmq::socket_t(m_context->getContext(), ZMQ_REQ));
// Set the linger value to 0 to ensure that pending requests are destroyed in case of timeout.
int value = 0;
m_socket->setsockopt(ZMQ_LINGER, &value, sizeof(int));
try {
// Connect to the endpoint.
m_socket->connect(m_endpoint.c_str());
}
catch (exception const & e) {
throw SocketException(e.what());
}
// Apply the linger to the socket.
setSocketLinger();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment