Socket behavior Socket limits in API mode
Digi XBee3 Cellular LTE-M/NB-IoT Global Smart Modem User Guide
147
Socket limits in API mode
Note For NB-IoT, TCP support is dependent on the network. Contact your network provider for
details.
In API mode there are a fixed number of sockets available; see Supported sockets. When a Transmit
(TX) Request: IPv4 - 0x20 frame is sent to the XBee Smart Modem for a new destination, it creates a
new socket. The exception to this is when using the UDP protocol with the C0 source port, which
allows unlimited destinations on the socket created by C0 (Source Port). If no more sockets are
available, the device sends back a Transmit (TX) Status - 0x89 frame with a Resource Error. The
Resource Error resolves when an existing socket is closed. An existing socket may be closed when the
socket times out (see TM (IP Client Connection Timeout) and TS (IP Server Connection Timeout)) or
when the socket is closed via a TX request with the CLOSE flag set.
In API mode each socket has a maximum number of pending Transmit (TX) Requests allowed. When a
Transmit (TX) Request: IPv4 - 0x20 frame is sent to the XBee Smart Modem for an existing destination,
it sends that request using the socket for that destination. If the number of pending Transmit (TX)
Requests would be exceeded for the socket, the device sends back a Transmit (TX) Status - 0x89
frame with a Resource Error indicating that the device is not able to send the request and should retry
again later. The Resource Error resolves when a Transmit (TX) Request that is pending on the socket
is transmitted; this is indicated by the Transmit (TX) Status frame for the request.
Enable incoming TCP sockets in API mode
In API mode, you can enable incoming connections to the XBee Smart Modem.
Note For NB-IoT, TCP support is dependent on the network. Contact your network provider for
details.
1. To enable listening, set C0 (Source Port) to the value of the listening port.
2. To use TCP for client and server socket connections, set IP (IP Protocol) to 0x01.
The listener allows multiple clients (incoming connections), up to the limit of the maximum number of
sockets on the system.
When the XBee Smart Modem receives RF data on the port defined by C0, you get a Receive (RX)
Packet: IPv4 - 0xB0 with the incoming address and port.
If you want to communicate back to the incoming connection, use the Transmit (TX) Request: IPv4 -
0x20 and enter the received address and port as the destination address and port, along with the
listening (C0) local source port.
API mode behavior for outgoing TCP and SSL connections
To initiate an outgoing TCP or SSL connection to a remote host, send a Transmit (TX) Request: IPv4 -
0x20 frame to the XBee Smart Modem's serial port specifying the destination address and destination
port for the remote host; the data is optional and the source port is 0.
Note For NB-IoT, TCP support is dependent on the network. Contact your network provider for
details.
If the connection is disconnected at any time, send a Transmit TX Request frame to trigger a new
connection attempt.
To send data over this connection use the Transmit (TX) Request: IPv4 - 0x20.