
This is an example based on mbed-os cellular APIs that demonstrates a TCP or UDP echo transaction with a public echo server.
Revision 42:cab443dff75e, committed 2019-05-29
- Comitter:
- mbed_official
- Date:
- Wed May 29 08:01:56 2019 +0100
- Parent:
- 41:1f13c9a6ee23
- Child:
- 43:fef5b8b23c60
- Commit message:
- Merge pull request #143 from statropy/statropy-patch-1
Use the actual length of the test string payload
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-cellular
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu May 16 09:02:09 2019 +0100 +++ b/main.cpp Wed May 29 08:01:56 2019 +0100 @@ -173,7 +173,7 @@ sock.set_timeout(15000); #if MBED_CONF_APP_SOCK_TYPE == NONIP - retcode = sock.send((void*) echo_string, sizeof(echo_string)); + retcode = sock.send((void*) echo_string, strlen(echo_string)); if (retcode < 0) { print_function("CellularNonIPSocket.send() fails, code: %d\n", retcode); return -1; @@ -202,7 +202,7 @@ } else { print_function("TCP: connected with %s server\n", host_name); } - retcode = sock.send((void*) echo_string, sizeof(echo_string)); + retcode = sock.send((void*) echo_string, strlen(echo_string)); if (retcode < 0) { print_function("TCPSocket.send() fails, code: %d\n", retcode); return -1; @@ -213,7 +213,7 @@ n = sock.recv((void*) recv_buf, sizeof(recv_buf)); #else - retcode = sock.sendto(sock_addr, (void*) echo_string, sizeof(echo_string)); + retcode = sock.sendto(sock_addr, (void*) echo_string, strlen(echo_string)); if (retcode < 0) { print_function("UDPSocket.sendto() fails, code: %d\n", retcode); return -1;