
-57-
v4.9
TCP and UDP connections
11.6.1. Enable the multi client mode
The function
createSocket()
with the parameter
MULTI_CONNECTION
must be used to enable the multi client mode.
Example of use:
{
// Enables the multi client mode:
_3G.createSocket(MULTI_CONNECTION);
}
This function returns:
•
‘1’ on success
•
‘-2’ if error opening the network
•
‘-3’ if error opening the network with CME error code available
•
‘-4’ if error opening the network with IP error code available
11.6.2. Creating sockets
To open a socket in multi client mode the function
createMultiSocket()
, must be used. To open a TCP socket the next
parameters must be specified: number of the link, IP address of the server and port of the server. To open a UDP socket only
need the number of the link and the listen port.
Example of use:
{
// Creates a TCP connection in multi client mode:
_3G.createMultiSocket(2, “90.12.54.132”, 5566);
// Creates a UDP connection in multi client mode:
_3G.createMultiSocket(1, 156);
}
This function returns:
•
‘1’ on success
•
‘0’ if error
•
‘-2’ if not configured in multi client mode
•
‘-3’ if network is closed
•
‘-4’ error opening the connection with CME error code available
•
‘-5’ error opening the connection with IP error code available
11.6.3. Sending and receiving data
To send data to a TCP connection the parameters needed are the number of the connection and the string of data. For send
data to a UDP connection the parameters are the number of the connection, the string of data, the IP address of the server and
the port of the server.
Example of use:
{
// Sending data to a TCP socket:
_3G.sendData(2, “TCP test string”);
// Sending data to a UDP socket:
_3G.sendData(1, “UDP test string”, “90.12.54.136”, 5577);
}