static VALUE rg_initialize(VALUE self, VALUE hostname, VALUE port, VALUE priority, VALUE weight) { /* TODO: Does this work with boxed? */ /* TODO: hostname should be infected when returned. */ G_INITIALIZE(self, g_srv_target_new(RVAL2CSTR(hostname), RVAL2GUINT16(port), RVAL2GUINT16(priority), RVAL2GUINT16(weight))); return Qnil; }
static VALUE rg_initialize(VALUE self, VALUE hostname, VALUE port) { G_INITIALIZE(self, g_network_address_new(RVAL2CSTR(hostname), RVAL2GUINT16(port))); return Qnil; }
static VALUE rg_initialize(VALUE self, VALUE address, VALUE port) { G_INITIALIZE(self, g_inet_socket_address_new(RVAL2GINETADDRESS(address), RVAL2GUINT16(port))); return Qnil; }
static VALUE rg_s_parse(G_GNUC_UNUSED VALUE self, VALUE host_and_port, VALUE default_port) { GError *error = NULL; GSocketConnectable *connectable; connectable = g_network_address_parse(RVAL2CSTR(host_and_port), RVAL2GUINT16(default_port), &error); if (connectable == NULL) rbgio_raise_error(error); return GOBJ2RVAL_UNREF(connectable); }
static VALUE rg_connect_to_host(int argc, VALUE *argv, VALUE self) { VALUE host_and_port, default_port, cancellable; GError *error = NULL; GSocketConnection *connection; rb_scan_args(argc, argv, "21", &host_and_port, &default_port, &cancellable); connection = g_socket_client_connect_to_host(_SELF(self), RVAL2CSTR(host_and_port), RVAL2GUINT16(default_port), RVAL2GCANCELLABLE(cancellable), &error); if (connection == NULL) rbgio_raise_error(error); return self; }
static VALUE rg_connect_to_host_async(int argc, VALUE *argv, VALUE self) { VALUE rbhost_and_port, rbdefault_port, rbcancellable, block; GCancellable *cancellable; const gchar *host_and_port; guint16 default_port; rb_scan_args(argc, argv, "21&", &rbhost_and_port, &rbdefault_port, &rbcancellable, &block); host_and_port = RVAL2CSTR(rbhost_and_port); default_port = RVAL2GUINT16(rbdefault_port); cancellable = RVAL2GCANCELLABLE(rbcancellable); SAVE_BLOCK(block); g_socket_client_connect_to_host_async(_SELF(self), host_and_port, default_port, cancellable, rbgio_async_ready_callback, (gpointer)block); return self; }