Class: NanoMsg::SurveySocket

Inherits:
Socket
  • Object
show all
Defined in:
ext/init.c

Instance Method Summary collapse

Methods inherited from Socket

#bind, #close, #connect, #recv, #send, #setsockopt

Constructor Details

#initializeObject

Instance Method Details

#deadlineObject



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'ext/init.c', line 350

static VALUE
srvy_get_deadline(VALUE self)
{
  int sock = sock_get(self);
  int deadline; 
  size_t size = sizeof(int);

  int err; 

  err = nn_getsockopt(sock, NN_SURVEYOR, NN_SURVEYOR_DEADLINE, &deadline, &size);
  if (err < 0)
    RAISE_SOCK_ERROR; 

  return rb_funcall(INT2NUM(deadline), rb_intern("/"), 1, rb_float_new(1000));  
}

#deadline=(deadline) ⇒ Object



335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'ext/init.c', line 335

static VALUE
srvy_set_deadline(VALUE self, VALUE deadline)
{
  int sock = sock_get(self);
  VALUE miliseconds = rb_funcall(deadline, rb_intern("*"), 1, INT2NUM(1000));
  int timeout = FIX2INT(miliseconds);
  int err; 

  err = nn_setsockopt(sock, NN_SURVEYOR, NN_SURVEYOR_DEADLINE, &timeout, sizeof(int));
  if (err < 0)
    RAISE_SOCK_ERROR;

  return deadline; 
}