gSocketReceive: gSocketReceive

Description Usage Arguments Details Value Author(s)

View source: R/gioFuncs.R

Description

Receive data (up to size bytes) from a socket. This is mainly used by connection-oriented sockets; it is identical to gSocketReceiveFrom with address set to NULL.

Usage

1
gSocketReceive(object, size, cancellable = NULL, .errwarn = TRUE)

Arguments

object

a GSocket

size

the number of bytes you want to read from the socket

cancellable

a GCancellable or NULL

.errwarn

Whether to issue a warning on error or fail silently

Details

For G_SOCKET_TYPE_DATAGRAM and G_SOCKET_TYPE_SEQPACKET sockets, gSocketReceive will always read either 0 or 1 complete messages from the socket. If the received message is too large to fit in buffer, then the data beyond size bytes will be discarded, without any explicit indication that this has occurred.

For G_SOCKET_TYPE_STREAM sockets, gSocketReceive can return any number of bytes, up to size. If more than size bytes have been received, the additional data will be returned in future calls to gSocketReceive.

If the socket is in blocking mode the call will block until there is some data to receive or there is an error. If there is no data available and the socket is in non-blocking mode, a G_IO_ERROR_WOULD_BLOCK error will be returned. To be notified when data is available, wait for the G_IO_IN condition.

On error -1 is returned and error is set accordingly. Since 2.22

Value

A list containing the following elements:

retval

[integer] Number of bytes read, or -1 on error

buffer

a buffer to read data into (which should be at least size bytes long).

error

GError for error reporting, or NULL to ignore.

Author(s)

Derived by RGtkGen from GTK+ documentation


RGtk2 documentation built on Oct. 14, 2021, 5:08 p.m.

Related to gSocketReceive in RGtk2...