Example #1
0
static VALUE t_get_peername (VALUE self, VALUE signature)
{
	struct sockaddr s;
	if (evma_get_peername (NUM2ULONG (signature), &s)) {
		return rb_str_new ((const char*)&s, sizeof(s));
	}

	return Qnil;
}
static VALUE t_get_peername (VALUE self, VALUE signature)
{
    char buf[1024];
    socklen_t len = sizeof buf;
    if (evma_get_peername (NUM2ULONG (signature), (struct sockaddr*)buf, &len)) {
        return rb_str_new (buf, len);
    }

    return Qnil;
}
Example #3
0
static VALUE t_get_peername (VALUE self UNUSED, VALUE signature)
{
	char buf[1024];
	socklen_t len = sizeof buf;
	try {
		if (evma_get_peername (NUM2BSIG (signature), (struct sockaddr*)buf, &len)) {
			return rb_str_new (buf, len);
		}
	} catch (std::runtime_error e) {
		rb_raise (rb_eRuntimeError, "%s", e.what());
	}

	return Qnil;
}