- return G_SOCKET (g_object_new (G_TYPE_SOCKET, "fd", sock, NULL));
+ default:
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "unsupported socket type");
+ return NULL;
+ }
+
+ if (protocol == NULL)
+ native_protocol = 0;
+ else
+ {
+ struct protoent *ent;
+ g_static_mutex_lock (&getprotobyname_mutex);
+ if (!(ent = getprotobyname (protocol)))
+ {
+ g_static_mutex_unlock (&getprotobyname_mutex);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "unsupported socket protocol");
+ return NULL;
+ }
+ native_protocol = ent->p_proto;
+ g_static_mutex_unlock (&getprotobyname_mutex);
+ }
+
+ fd = socket(native_domain, native_type, native_protocol);
+
+ if (fd < 0)
+ {
+ g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno), "unable to create socket: %s", g_strerror (errno));
+ return NULL;
+ }
+
+ return G_SOCKET (g_object_new (G_TYPE_SOCKET, "fd", fd, NULL));