posilani dat

Dependencies:   FatFileSystemCpp mbed PowerControl USBHostLite

Committer:
PavelKumpan
Date:
Tue May 23 18:42:14 2017 +0000
Revision:
26:5674b8978551
Parent:
7:805c16a071d0
Recreated communication protocol.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jkaderka 7:805c16a071d0 1 /* Copyright (C) 2012 mbed.org, MIT License
jkaderka 7:805c16a071d0 2 *
jkaderka 7:805c16a071d0 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
jkaderka 7:805c16a071d0 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
jkaderka 7:805c16a071d0 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
jkaderka 7:805c16a071d0 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
jkaderka 7:805c16a071d0 7 * furnished to do so, subject to the following conditions:
jkaderka 7:805c16a071d0 8 *
jkaderka 7:805c16a071d0 9 * The above copyright notice and this permission notice shall be included in all copies or
jkaderka 7:805c16a071d0 10 * substantial portions of the Software.
jkaderka 7:805c16a071d0 11 *
jkaderka 7:805c16a071d0 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
jkaderka 7:805c16a071d0 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
jkaderka 7:805c16a071d0 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
jkaderka 7:805c16a071d0 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
jkaderka 7:805c16a071d0 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
jkaderka 7:805c16a071d0 17 */
jkaderka 7:805c16a071d0 18
jkaderka 7:805c16a071d0 19 #ifndef TCPSOCKET_H
jkaderka 7:805c16a071d0 20 #define TCPSOCKET_H
jkaderka 7:805c16a071d0 21
jkaderka 7:805c16a071d0 22 #include "Socket.h"
jkaderka 7:805c16a071d0 23 #include "Endpoint.h"
jkaderka 7:805c16a071d0 24
jkaderka 7:805c16a071d0 25 /**
jkaderka 7:805c16a071d0 26 TCP socket connection
jkaderka 7:805c16a071d0 27 */
jkaderka 7:805c16a071d0 28 class TCPSocketConnection: public Socket, public Endpoint {
jkaderka 7:805c16a071d0 29
jkaderka 7:805c16a071d0 30 public:
jkaderka 7:805c16a071d0 31 /** TCP socket connection
jkaderka 7:805c16a071d0 32 */
jkaderka 7:805c16a071d0 33 TCPSocketConnection();
jkaderka 7:805c16a071d0 34
jkaderka 7:805c16a071d0 35 /** Connects this TCP socket to the server
jkaderka 7:805c16a071d0 36 \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS.
jkaderka 7:805c16a071d0 37 \param port The host's port to connect to.
jkaderka 7:805c16a071d0 38 \return 0 on success, -1 on failure.
jkaderka 7:805c16a071d0 39 */
jkaderka 7:805c16a071d0 40 int connect(const char* host, const int port);
jkaderka 7:805c16a071d0 41
jkaderka 7:805c16a071d0 42 /** Check if the socket is connected
jkaderka 7:805c16a071d0 43 \return true if connected, false otherwise.
jkaderka 7:805c16a071d0 44 */
jkaderka 7:805c16a071d0 45 bool is_connected(void);
jkaderka 7:805c16a071d0 46
jkaderka 7:805c16a071d0 47 /** Send data to the remote host.
jkaderka 7:805c16a071d0 48 \param data The buffer to send to the host.
jkaderka 7:805c16a071d0 49 \param length The length of the buffer to send.
jkaderka 7:805c16a071d0 50 \return the number of written bytes on success (>=0) or -1 on failure
jkaderka 7:805c16a071d0 51 */
jkaderka 7:805c16a071d0 52 int send(char* data, int length);
jkaderka 7:805c16a071d0 53
jkaderka 7:805c16a071d0 54 /** Send all the data to the remote host.
jkaderka 7:805c16a071d0 55 \param data The buffer to send to the host.
jkaderka 7:805c16a071d0 56 \param length The length of the buffer to send.
jkaderka 7:805c16a071d0 57 \return the number of written bytes on success (>=0) or -1 on failure
jkaderka 7:805c16a071d0 58 */
jkaderka 7:805c16a071d0 59 int send_all(char* data, int length);
jkaderka 7:805c16a071d0 60
jkaderka 7:805c16a071d0 61 /** Receive data from the remote host.
jkaderka 7:805c16a071d0 62 \param data The buffer in which to store the data received from the host.
jkaderka 7:805c16a071d0 63 \param length The maximum length of the buffer.
jkaderka 7:805c16a071d0 64 \return the number of received bytes on success (>=0) or -1 on failure
jkaderka 7:805c16a071d0 65 */
jkaderka 7:805c16a071d0 66 int receive(char* data, int length);
jkaderka 7:805c16a071d0 67
jkaderka 7:805c16a071d0 68 /** Receive all the data from the remote host.
jkaderka 7:805c16a071d0 69 \param data The buffer in which to store the data received from the host.
jkaderka 7:805c16a071d0 70 \param length The maximum length of the buffer.
jkaderka 7:805c16a071d0 71 \return the number of received bytes on success (>=0) or -1 on failure
jkaderka 7:805c16a071d0 72 */
jkaderka 7:805c16a071d0 73 int receive_all(char* data, int length);
jkaderka 7:805c16a071d0 74 };
jkaderka 7:805c16a071d0 75
jkaderka 7:805c16a071d0 76 #endif