Constructor
GioSocketnew_from_fd
since: 2.22
Declaration [src]
GSocket*
g_socket_new_from_fd (
gint fd,
GError** error
)
Description [src]
Creates a new GSocket
from a native file descriptor
or winsock SOCKET handle.
This reads all the settings from the file descriptor so that
all properties should work. Note that the file descriptor
will be set to non-blocking mode, independent on the blocking
mode of the GSocket
.
On success, the returned GSocket
takes ownership of fd
. On failure, the
caller must close fd
themselves.
Since GLib 2.46, it is no longer a fatal error to call this on a non-socket
descriptor. Instead, a GError will be set with code G_IO_ERROR_FAILED
.
Available since: 2.22
Parameters
fd
-
Type:
gint
A native socket file descriptor.
error
-
Type:
GError **
The return location for a recoverable error.
The argument can be NULL
.If the return location is not NULL
, then you must initialize it to aNULL
GError*
.The argument will be left initialized to NULL
by the constructor if there are no errors.In case of error, the argument will be set to a newly allocated GError
; the caller will take ownership of the data, and be responsible for freeing it.
Return value
Type: GSocket
A GSocket
or NULL
on error.
Free the returned object with g_object_unref().
The caller of the function takes ownership of the data, and is responsible for freeing it. |