#include <Socket_ZMQ4.hpp>
Definition at line 141 of file Socket_ZMQ4.hpp.
opentxs::OTSocket_ZMQ_4::OTSocket_ZMQ_4 |
( |
| ) |
|
opentxs::OTSocket_ZMQ_4::~OTSocket_ZMQ_4 |
( |
| ) |
|
bool opentxs::OTSocket_ZMQ_4::Connect |
( |
| ) |
|
|
virtual |
Implements opentxs::OTSocket.
Definition at line 274 of file Socket_ZMQ4.cpp.
284 OTLog::vError(
"%s: Error: %s must exist to Listen!\n", __FUNCTION__,
285 "m_pzmq->context_zmq");
289 OTLog::vError(
"%s: Error: Must not be Listening, to Connect!\n",
298 if (!NewSocket(
true))
return false;
303 catch (std::exception& e) {
304 OTLog::vError(
"%s: Exception Caught: %s \n", __FUNCTION__, e.what());
static EXPORT void vError(const char *szError,...)
OTString m_strConnectPath
zmq::context_t * context_zmq
zmq::socket_t * socket_zmq
EXPORT bool Exists() const
EXPORT const char * Get() const
bool opentxs::OTSocket_ZMQ_4::Connect |
( |
const OTString & |
strConnectPath | ) |
|
|
virtual |
Implements opentxs::OTSocket.
Definition at line 353 of file Socket_ZMQ4.cpp.
355 if (!strConnectPath.Exists()) {
360 if (5 > strConnectPath.GetLength()) {
static EXPORT void vError(const char *szError,...)
OTString m_strConnectPath
bool opentxs::OTSocket_ZMQ_4::Listen |
( |
| ) |
|
|
virtual |
Implements opentxs::OTSocket.
Definition at line 312 of file Socket_ZMQ4.cpp.
322 OTLog::vError(
"%s: Error: %s must exist to Listen!\n", __FUNCTION__,
323 "m_pzmq->context_zmq");
327 OTLog::vError(
"%s: Error: Must not be Connected, to Listen!\n",
336 if (!NewSocket(
false))
return false;
344 catch (std::exception& e) {
345 OTLog::vError(
"%s: Exception Caught: %s \n", __FUNCTION__, e.what());
static EXPORT void vError(const char *szError,...)
zmq::context_t * context_zmq
zmq::socket_t * socket_zmq
OTString m_strBindingPath
EXPORT bool Exists() const
EXPORT const char * Get() const
bool opentxs::OTSocket_ZMQ_4::Listen |
( |
const OTString & |
strBindingPath | ) |
|
|
virtual |
Implements opentxs::OTSocket.
Definition at line 371 of file Socket_ZMQ4.cpp.
373 if (!strBindingPath.Exists()) {
378 if (5 > strBindingPath.GetLength()) {
static EXPORT void vError(const char *szError,...)
OTString m_strBindingPath
bool opentxs::OTSocket_ZMQ_4::NewContext |
( |
| ) |
|
|
virtual |
Implements opentxs::OTSocket.
Definition at line 229 of file Socket_ZMQ4.cpp.
235 if (!CloseSocket(
true))
return false;
245 catch (std::exception& e) {
246 OTLog::vError(
"%s: Exception Caught: %s \n", __FUNCTION__, e.what());
static EXPORT void vError(const char *szError,...)
zmq::context_t * context_zmq
bool opentxs::OTSocket_ZMQ_4::Receive |
( |
OTString & |
strServerReply | ) |
|
|
virtual |
Implements opentxs::OTSocket.
Definition at line 521 of file Socket_ZMQ4.cpp.
530 OTLog::vError(
"%s: Error: %s must exist to Receive!\n", __FUNCTION__,
531 "m_pzmq->context_zmq");
538 OTLog::vError(
"%s: Error: %s must exist to Receive!\n", __FUNCTION__,
539 "m_pzmq->socket_zmq");
547 zmq::message_t zmq_message;
549 bool bSuccessReceiving =
false;
559 catch (std::exception& e) {
567 int64_t lDoubling = lLatencyRecvMilliSec;
569 bool expect_reply =
true;
570 while (expect_reply) {
572 zmq::pollitem_t items[] = {{*m_pzmq->
socket_zmq, 0, ZMQ_POLLIN, 0}};
576 nPoll = zmq::poll(&items[0], 1, static_cast<long>(lDoubling));
578 catch (std::exception& e) {
587 if (items[0].revents & ZMQ_POLLIN) {
593 catch (std::exception& e) {
600 if (!bSuccessReceiving) {
601 if (!HandleReceivingError()) expect_reply =
false;
606 else if (nReceiveTries == 0) {
608 expect_reply =
false;
611 else if ((-1) == nPoll)
613 if (!HandlePollingError()) expect_reply =
false;
620 if (bSuccessReceiving && (zmq_message.size() > 0))
621 strServerReply.MemSet(static_cast<const char*>(zmq_message.data()),
622 static_cast<uint32_t>(zmq_message.size()));
624 return (bSuccessReceiving && (zmq_message.size() > 0));
static EXPORT void vError(const char *szError,...)
int32_t m_nLatencyReceiveNoTries
zmq::context_t * context_zmq
zmq::socket_t * socket_zmq
int64_t m_lLatencyReceiveMs
static EXPORT bool SleepMilliseconds(int64_t lMilliseconds)
bool opentxs::OTSocket_ZMQ_4::RemakeSocket |
( |
const bool |
bNewContext = false | ) |
|
|
virtual |
bool opentxs::OTSocket_ZMQ_4::Send |
( |
const OTASCIIArmor & |
ascEnvelope | ) |
|
|
virtual |
Implements opentxs::OTSocket.
Definition at line 389 of file Socket_ZMQ4.cpp.
395 if (0 >= ascEnvelope.GetLength()) {
396 OTLog::vError(
"%s: Error: %s is zero length!\n", __FUNCTION__,
406 OTLog::vError(
"%s: Error: %s must exist to Send!\n", __FUNCTION__,
407 "m_pzmq->context_zmq");
414 OTLog::vError(
"%s: Error: %s must exist to Send!\n", __FUNCTION__,
415 "m_pzmq->socket_zmq");
422 zmq::message_t zmq_message(ascEnvelope.GetLength());
423 memcpy((
void*)zmq_message.data(), ascEnvelope.Get(),
424 ascEnvelope.GetLength());
426 bool bSuccessSending =
false;
433 catch (std::exception& e) {
442 int64_t lDoubling = lLatencySendMilliSec;
443 bool bKeepTrying =
true;
445 while (bKeepTrying && (nSendTries > 0)) {
446 zmq::pollitem_t items[] = {
452 zmq::poll(&items[0], 1,
453 static_cast<long>(lDoubling));
457 catch (std::exception& e) {
465 if (items[0].revents & ZMQ_POLLOUT) {
471 catch (std::exception& e) {
479 if (!bSuccessSending) {
480 if (!HandleSendingError()) bKeepTrying =
false;
485 else if ((-1) == nPoll)
487 if (!HandlePollingError()) bKeepTrying =
false;
506 return bSuccessSending;
static EXPORT void vError(const char *szError,...)
int64_t m_lLatencyDelayAfter
int32_t m_nLatencySendNoTries
zmq::context_t * context_zmq
zmq::socket_t * socket_zmq
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
static EXPORT bool SleepMilliseconds(int64_t lMilliseconds)
OTASCIIArmor m_ascLastMsgSent
bool opentxs::OTSocket_ZMQ_4::Send |
( |
const OTASCIIArmor & |
ascEnvelope, |
|
|
const OTString & |
strConnectPath |
|
) |
| |
|
virtual |
Implements opentxs::OTSocket.
Definition at line 509 of file Socket_ZMQ4.cpp.
514 if (!bNewPath)
Connect(strConnectPath);
518 return Send(ascEnvelope);
OTString m_strConnectPath
EXPORT bool Send(const OTASCIIArmor &ascEnvelope)
EXPORT bool Compare(const char *compare) const
The documentation for this class was generated from the following files: