-27-
v7.0
Software
3.11.5. Receiving data
The
receive()
function allows the user to receive TCP/UDP packets once the socket is active. The function needs
different inputs:
•
Socket ID
: the socket identifier used for opening the connection.
•
Timeout (optional input):
-
If no timeout input is specified, the receive function is a non-blocking function which answers if data has
been received.
-
If the timeout is inserted as new input, the function will block until a new packet is received or time is up in
the case no packet is received. This timeout must be specified in milliseconds units.
Example for instant reception:
{
BG96.receive(WaspBG96::CONNECTION_1);
}
Example for blocking reception (i.e. 30 seconds):
{
BG96.receive(WaspBG96::CONNECTION_1, 30000);
}
Related variables:
BG96._buffer
→
Pointer to the buffer where received data is stored
BG96._length
→
Length of the data received
Possible error codes for this function:
1: if no data received
2: if error getting socket info
3: if timeout waiting for data
4: if error receiving data from module
5: if error parsing length of data
6: if error reading incoming bytes