cassyarduino cassyarduino / UIPEthernet
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Client.h Source File

Client.h

00001 /*
00002   Client.h - Base class that provides Client
00003   Copyright (c) 2011 Adrian McEwen.  All right reserved.
00004 
00005   Modified (ported to mbed) by Zoltan Hudak <hudakz@inbox.com>
00006 
00007   This library is free software; you can redistribute it and/or
00008   modify it under the terms of the GNU Lesser General Public
00009   License as published by the Free Software Foundation; either
00010   version 2.1 of the License, or (at your option) any later version.
00011 
00012   This library is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015   Lesser General Public License for more details.
00016 
00017   You should have received a copy of the GNU Lesser General Public
00018   License along with this library; if not, write to the Free Software
00019   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 */
00021 #if !defined(ARDUINO_ARCH_AVR) && !defined(ARDUINO_ARCH_SAM)
00022 #ifndef client_h
00023   #define client_h
00024   #if defined(__MBED__)
00025     #include "mbed/IPAddress.h"
00026   #endif
00027 
00028   #if defined(ARDUINO)
00029     #include "IPAddress.h"
00030   #endif
00031 
00032 class   Client
00033 {
00034 public:
00035     virtual ~Client(){};
00036     virtual int         connect(IPAddress ip, uint16_t port) = 0;
00037     virtual int         connect(const char* host, uint16_t port) = 0;
00038     virtual size_t      write(uint8_t) = 0;
00039     virtual size_t      write(const uint8_t* buf, size_t size) = 0;
00040     virtual int         available(void) = 0;
00041     virtual int         read(void) = 0;
00042     virtual int         read(uint8_t* buf, size_t size) = 0;
00043     virtual int         peek(void) = 0;
00044     virtual void        flush(void) = 0;
00045     virtual void        stop(void) = 0;
00046     virtual uint8_t     connected(void) = 0;
00047     virtual operator    bool(void) = 0;
00048 protected:
00049     uint8_t*    rawIPAddress(IPAddress& addr)   { return addr.raw_address(); };
00050 };
00051 #endif
00052 #endif