9.15.1.8 +SOCKRD

This command is used to read data from a socket. Two AECs present notification of data received by the DCE:

  • +SOCKRXU indicates UDP data has been received.
  • +SOCKRXT indicates TCP data has been received.

The DTE is responsible for retrieving the datagram/stream data via the +SOCKRD command.

For TCP sockets the DCE will indicate, via +SOCKRXT, the number of bytes of data which are currently available for reading via the +SOCKRD command. The DCE may issue multiple +SOCKRXT AECs as data is received. When requesting data via the +SOCKRD command the DTE may receive less data than request, the number of bytes provided by the DCE will be declared in the +SOCKRD response before the data is presented. The DTE may request less data than that declared by the +SOCKRXT AEC as being available, the remaining data will be available for subsequent reading.

For UDP sockets the DCE will indicate, via +SOCKRXU, the number of bytes of data which were received in the oldest datagram received by the DCE. Only a single +SOCKRXU will be issued by the DCE even if subsequent UDP datagrams are received. Reading data from the UDP socket via the +SOCKRD command will read and discard the current datagram, if less data is requested than was indicated by the +SOCKRXU AEC the remaining unread data in the datagram will be discarded.

Security – Default Security for the command is: GGGG

Table 9-139. Command Syntax

Command

Description

Security

AT+SOCKRD=<SOCK_ID>,<OUTPUT_MODE>,<LENGTH>

Socket read

GGGG

Table 9-140. Command Parameter Syntax

Parameter Name

Type

Description

<SOCK_ID>

Integer

The socket ID. Valid range is 1-65535

<OUTPUT_MODE>

Integer

The format the DTE wishes to receive the data
  • 1 – ASCII or hex string
  • 2 – Binary

<LENGTH>

Integer

The number of bytes the DTE wishes to read

Table 9-141. Response Syntax

Response

Description

+SOCKRD:<SOCK_ID>,<LENGTH>,<DATA>

Socket read response

Table 9-142. Response Element Syntax

Element Name

Type

Description

<SOCK_ID>

Integer

The socket ID. Valid range is 1-65535

<LENGTH>

Integer

Number of bytes

<DATA>

Byte Array

The data in the format requested