Method
GioSocketreceive_bytes_from
since: 2.80
Declaration [src]
GBytes*
g_socket_receive_bytes_from (
GSocket* socket,
GSocketAddress** address,
gsize size,
gint64 timeout_us,
GCancellable* cancellable,
GError** error
)
Description [src]
Receive data (up to size
bytes) from a socket.
This function is a variant of g_socket_receive_from()
which returns
a GBytes
rather than a plain buffer.
If address
is non-NULL
then address
will be set equal to the
source address of the received packet.
The address
is owned by the caller.
Pass -1
to timeout_us
to block indefinitely until data is received (or
the connection is closed, or there is an error). Pass 0
to use the default
timeout from GSocket:timeout
, or pass a positive number to wait
for that many microseconds for data before returning G_IO_ERROR_TIMED_OUT
.
Available since: 2.80
Parameters
address
-
Type:
GSocketAddress
Return location for a
GSocketAddress
.The argument will be set by the function. The argument can be NULL
.The caller of the method takes ownership of the returned data, and is responsible for freeing it. size
-
Type:
gsize
The number of bytes you want to read from the socket.
timeout_us
-
Type:
gint64
The timeout to wait for, in microseconds, or
-1
to block indefinitely. cancellable
-
Type:
GCancellable
A
GCancellable
, orNULL
.The argument can be NULL
.The data is owned by the caller of the method. 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 method 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: GBytes
A bytes buffer containing the
received bytes, or NULL
on error.
The caller of the method takes ownership of the returned data, and is responsible for freeing it. |