Commits

Anonymous committed 0a4d49a Merge

Merge pull request #23 from skaes/socket-timeouts

support socket timeouts

Comments (0)

Files changed (1)

  * [Default value] N/A
  * [Applicable socket types] all
  *
+ * == ZMQ::SNDTIMEO
+ * Retrieves the timeout for send operations on the socket.
+ *
+ * If the value is 0, a send operation on the socket will return immediately, with a
+ * EAGAIN error if the message cannot be sent. If the value is -1, it will block until the
+ * message is sent. For all other values, it will try to send the message for that amount
+ * of time before returning with an EAGAIN error.
+ *
+ * [Option value type] Integer
+ * [Option value unit] milliseconds
+ * [Default value] -1 (infinite)
+ * [Applicable socket types] all
+ *
+ * == ZMQ::RCVTIMEO
+ * Retrieves the timeout for receive operations on the socket.
+ *
+ * If the value is 0, a receive operation on the socket will return immediately, with a
+ * EAGAIN error if there is no message to receive. If the value is -1, it will block until
+ * a message is available. For all other values, it will wait for a message for that
+ * amount of time before returning with an EAGAIN error.
+ *
+ * [Option value type] Integer
+ * [Option value unit] milliseconds
+ * [Default value] -1 (infinite)
+ * [Applicable socket types] all
+ *
  */
 static VALUE socket_getsockopt (VALUE self_, VALUE option_)
 {
 	case ZMQ_RECONNECT_IVL_MAX:
 	case ZMQ_RECOVERY_IVL_MSEC:
 #endif
+#if ZMQ_VERSION >= 20200
+        case ZMQ_SNDTIMEO:
+        case ZMQ_RCVTIMEO:
+#endif
         {
             int optval;
             size_t optvalsize = sizeof(optval);
  * [Default value] 100
  * [Applicable socket types] all, only for connection-oriented transports
  *
+ * == ZMQ::SNDTIMEO
+ * Sets the timeout for send operations on the socket.
+ *
+ * If the value is 0, a send operation on the socket will return immediately, with a
+ * EAGAIN error if the message cannot be sent. If the value is -1, it will block until the
+ * message is sent. For all other values, it will try to send the message for that amount
+ * of time before returning with an EAGAIN error.
+ *
+ * [Option value type] Integer
+ * [Option value unit] milliseconds
+ * [Default value] -1 (infinite)
+ * [Applicable socket types] all
+ *
+ * == ZMQ::RCVTIMEO
+ * Sets the timeout for receive operations on the socket.
+ *
+ * If the value is 0, a receive operation on the socket will return immediately, with a
+ * EAGAIN error if there is no message to receive. If the value is -1, it will block until
+ * a message is available. For all other values, it will wait for a message for that
+ * amount of time before returning with an EAGAIN error.
+ *
+ * [Option value type] Integer
+ * [Option value unit] milliseconds
+ * [Default value] -1 (infinite)
+ * [Applicable socket types] all
+ *
  */
 static VALUE socket_setsockopt (VALUE self_, VALUE option_,
     VALUE optval_)
     case ZMQ_RECONNECT_IVL_MAX:
     case ZMQ_RECOVERY_IVL_MSEC:
 #endif
+#if ZMQ_VERSION >= 20200
+    case ZMQ_SNDTIMEO:
+    case ZMQ_RCVTIMEO:
+#endif
         {
             int optval = FIX2INT (optval_);
 
     rb_define_const (zmq_module, "RECONNECT_IVL_MAX", INT2NUM (ZMQ_RECONNECT_IVL_MAX));
     rb_define_const (zmq_module, "RECOVERY_IVL_MSEC", INT2NUM (ZMQ_RECOVERY_IVL_MSEC));
 #endif
+#if ZMQ_VERSION >= 20200
+    rb_define_const (zmq_module, "SNDTIMEO", INT2NUM (ZMQ_SNDTIMEO));
+    rb_define_const (zmq_module, "RCVTIMEO", INT2NUM (ZMQ_RCVTIMEO));
+#endif
 
     rb_define_const (zmq_module, "NOBLOCK", INT2NUM (ZMQ_NOBLOCK));
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.