mbed OS5

Fork of UIPEthernet by Zoltan Hudak

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 #ifndef client_h
00022 #define client_h
00023 #include "IPAddress.h"
00024 
00025 class   Client
00026 {
00027 public:
00028     virtual int         connect(IPAddress ip, uint16_t port) = 0;
00029     virtual int         connect(const char* host, uint16_t port) = 0;
00030     virtual size_t      write(uint8_t) = 0;
00031     virtual size_t      write(const uint8_t* buf, size_t size) = 0;
00032     virtual int         available(void) = 0;
00033     virtual int         read(void) = 0;
00034     virtual int         read(uint8_t* buf, size_t size) = 0;
00035     virtual int         peek(void) = 0;
00036     virtual void        flush(void) = 0;
00037     virtual void        stop(void) = 0;
00038     virtual uint8_t     connected(void) = 0;
00039     virtual operator    bool(void) = 0;
00040 protected:
00041     uint8_t*    rawIPAddress(IPAddress& addr)   { return addr.raw_address(); };
00042 };
00043 #endif