Azure IoT common library
Dependents: STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more
tcpsocketconnection_c.cpp@49:6bb8b9a66642, 2018-10-04 (annotated)
- Committer:
- AzureIoTClient
- Date:
- Thu Oct 04 09:17:16 2018 -0700
- Revision:
- 49:6bb8b9a66642
- Parent:
- 0:fa2de1b79154
1.2.10
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Azure.IoT Build | 0:fa2de1b79154 | 1 | // Copyright (c) Microsoft. All rights reserved. |
Azure.IoT Build | 0:fa2de1b79154 | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
Azure.IoT Build | 0:fa2de1b79154 | 3 | |
Azure.IoT Build | 0:fa2de1b79154 | 4 | #include "mbed.h" |
Azure.IoT Build | 0:fa2de1b79154 | 5 | |
Azure.IoT Build | 0:fa2de1b79154 | 6 | #include <stddef.h> |
Azure.IoT Build | 0:fa2de1b79154 | 7 | #include "TCPSocketConnection.h" |
Azure.IoT Build | 0:fa2de1b79154 | 8 | #include "azure_c_shared_utility/tcpsocketconnection_c.h" |
Azure.IoT Build | 0:fa2de1b79154 | 9 | |
Azure.IoT Build | 0:fa2de1b79154 | 10 | |
Azure.IoT Build | 0:fa2de1b79154 | 11 | TCPSOCKETCONNECTION_HANDLE tcpsocketconnection_create(void) |
Azure.IoT Build | 0:fa2de1b79154 | 12 | { |
Azure.IoT Build | 0:fa2de1b79154 | 13 | return new TCPSocketConnection(); |
Azure.IoT Build | 0:fa2de1b79154 | 14 | } |
Azure.IoT Build | 0:fa2de1b79154 | 15 | |
Azure.IoT Build | 0:fa2de1b79154 | 16 | void tcpsocketconnection_set_blocking(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, bool blocking, unsigned int timeout) |
Azure.IoT Build | 0:fa2de1b79154 | 17 | { |
Azure.IoT Build | 0:fa2de1b79154 | 18 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
Azure.IoT Build | 0:fa2de1b79154 | 19 | tsc->set_blocking(blocking, timeout); |
Azure.IoT Build | 0:fa2de1b79154 | 20 | } |
Azure.IoT Build | 0:fa2de1b79154 | 21 | |
Azure.IoT Build | 0:fa2de1b79154 | 22 | void tcpsocketconnection_destroy(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle) |
Azure.IoT Build | 0:fa2de1b79154 | 23 | { |
Azure.IoT Build | 0:fa2de1b79154 | 24 | delete (TCPSocketConnection*)tcpSocketConnectionHandle; |
Azure.IoT Build | 0:fa2de1b79154 | 25 | } |
Azure.IoT Build | 0:fa2de1b79154 | 26 | |
Azure.IoT Build | 0:fa2de1b79154 | 27 | int tcpsocketconnection_connect(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, const char* host, const int port) |
Azure.IoT Build | 0:fa2de1b79154 | 28 | { |
Azure.IoT Build | 0:fa2de1b79154 | 29 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
Azure.IoT Build | 0:fa2de1b79154 | 30 | return tsc->connect(host, port); |
Azure.IoT Build | 0:fa2de1b79154 | 31 | } |
Azure.IoT Build | 0:fa2de1b79154 | 32 | |
Azure.IoT Build | 0:fa2de1b79154 | 33 | bool tcpsocketconnection_is_connected(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle) |
Azure.IoT Build | 0:fa2de1b79154 | 34 | { |
Azure.IoT Build | 0:fa2de1b79154 | 35 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
Azure.IoT Build | 0:fa2de1b79154 | 36 | return tsc->is_connected(); |
Azure.IoT Build | 0:fa2de1b79154 | 37 | } |
Azure.IoT Build | 0:fa2de1b79154 | 38 | |
Azure.IoT Build | 0:fa2de1b79154 | 39 | void tcpsocketconnection_close(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle) |
Azure.IoT Build | 0:fa2de1b79154 | 40 | { |
Azure.IoT Build | 0:fa2de1b79154 | 41 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
Azure.IoT Build | 0:fa2de1b79154 | 42 | tsc->close(); |
Azure.IoT Build | 0:fa2de1b79154 | 43 | } |
Azure.IoT Build | 0:fa2de1b79154 | 44 | |
Azure.IoT Build | 0:fa2de1b79154 | 45 | int tcpsocketconnection_send(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, const char* data, int length) |
Azure.IoT Build | 0:fa2de1b79154 | 46 | { |
Azure.IoT Build | 0:fa2de1b79154 | 47 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
Azure.IoT Build | 0:fa2de1b79154 | 48 | return tsc->send((char*)data, length); |
Azure.IoT Build | 0:fa2de1b79154 | 49 | } |
Azure.IoT Build | 0:fa2de1b79154 | 50 | |
Azure.IoT Build | 0:fa2de1b79154 | 51 | int tcpsocketconnection_send_all(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, const char* data, int length) |
Azure.IoT Build | 0:fa2de1b79154 | 52 | { |
Azure.IoT Build | 0:fa2de1b79154 | 53 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
Azure.IoT Build | 0:fa2de1b79154 | 54 | return tsc->send_all((char*)data, length); |
Azure.IoT Build | 0:fa2de1b79154 | 55 | } |
Azure.IoT Build | 0:fa2de1b79154 | 56 | |
Azure.IoT Build | 0:fa2de1b79154 | 57 | int tcpsocketconnection_receive(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, char* data, int length) |
Azure.IoT Build | 0:fa2de1b79154 | 58 | { |
Azure.IoT Build | 0:fa2de1b79154 | 59 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
Azure.IoT Build | 0:fa2de1b79154 | 60 | return tsc->receive(data, length); |
Azure.IoT Build | 0:fa2de1b79154 | 61 | } |
Azure.IoT Build | 0:fa2de1b79154 | 62 | |
Azure.IoT Build | 0:fa2de1b79154 | 63 | int tcpsocketconnection_receive_all(TCPSOCKETCONNECTION_HANDLE tcpSocketConnectionHandle, char* data, int length) |
Azure.IoT Build | 0:fa2de1b79154 | 64 | { |
Azure.IoT Build | 0:fa2de1b79154 | 65 | TCPSocketConnection* tsc = (TCPSocketConnection*)tcpSocketConnectionHandle; |
Azure.IoT Build | 0:fa2de1b79154 | 66 | return tsc->receive_all(data, length); |
Azure.IoT Build | 0:fa2de1b79154 | 67 | } |