ソースの整理中ですが、利用はできます。

Dependencies:   EthernetInterface HttpServer TextLCD mbed-rpc mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
yueee_yt
Date:
Wed Mar 12 04:39:15 2014 +0000
Revision:
2:14b689a85306
Parent:
0:7766f6712673
bug fix

Who changed what in which revision?

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