Skip to content

Commit

Permalink
Add default timeout for the reading from socket operations
Browse files Browse the repository at this point in the history
  • Loading branch information
ellysh committed Feb 14, 2013
1 parent 3f3241f commit 4d96a67
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion source/common/answer.h
Expand Up @@ -27,7 +27,7 @@ class Answer
size_t GetSize() const;

void Send(Socket& socket) const;
bool Receive(Socket& socket, long timeout = -1);
bool Receive(Socket& socket, long timeout = kDefaultTimeout);

private:
mutable zmq_msg_t msg_;
Expand Down
2 changes: 1 addition & 1 deletion source/common/socket.h
Expand Up @@ -26,7 +26,7 @@ class Socket

void SendMsg(const zmq_msg_t& msg, const int flags) const;

bool ReceiveMsg(const long timeout = -1);
bool ReceiveMsg(const long timeout = kDefaultTimeout);
bool PopMsg(zmq_msg_t& msg);

void SetQueueSize(const int size);
Expand Down
1 change: 1 addition & 0 deletions source/common/types_zcache.h
Expand Up @@ -40,6 +40,7 @@ enum SocketType
kPubSub
};

static const long kDefaultTimeout = 3000;
static const port_t kErrorPort = -1;
static std::string kTcpProtocol = "tcp://";
static std::string kIpcProtocol = "ipc://";
Expand Down

0 comments on commit 4d96a67

Please sign in to comment.