コード例 #1
0
ファイル: rubymain.cpp プロジェクト: icecreamr/eventmachine
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;
}
コード例 #2
0
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;
}
コード例 #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;
}