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



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'ext/init.c', line 368

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



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

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; 
}