branch with improvemnts
Fork of M2XStreamClient by
Client.h@11:5c71c2948812, 2014-09-13 (annotated)
- Committer:
- mazgch
- Date:
- Sat Sep 13 15:49:53 2014 +0000
- Revision:
- 11:5c71c2948812
- Parent:
- 0:f479e4f4db0e
use local buffers and the flush or fill
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jb8414 | 0:f479e4f4db0e | 1 | #ifndef Client_h |
jb8414 | 0:f479e4f4db0e | 2 | #define Client_h |
jb8414 | 0:f479e4f4db0e | 3 | |
jb8414 | 0:f479e4f4db0e | 4 | #include "TCPSocketConnection.h" |
jb8414 | 0:f479e4f4db0e | 5 | |
jb8414 | 0:f479e4f4db0e | 6 | #include "Print.h" |
jb8414 | 0:f479e4f4db0e | 7 | #include "Utility.h" |
jb8414 | 0:f479e4f4db0e | 8 | |
jb8414 | 0:f479e4f4db0e | 9 | /* |
jb8414 | 0:f479e4f4db0e | 10 | * TCP Client |
jb8414 | 0:f479e4f4db0e | 11 | */ |
jb8414 | 0:f479e4f4db0e | 12 | class Client : public Print { |
jb8414 | 0:f479e4f4db0e | 13 | public: |
jb8414 | 0:f479e4f4db0e | 14 | Client(); |
jb8414 | 0:f479e4f4db0e | 15 | ~Client(); |
jb8414 | 0:f479e4f4db0e | 16 | |
jb8414 | 0:f479e4f4db0e | 17 | virtual int connect(const char *host, uint16_t port); |
jb8414 | 0:f479e4f4db0e | 18 | virtual size_t write(uint8_t); |
jb8414 | 0:f479e4f4db0e | 19 | virtual size_t write(const uint8_t *buf, size_t size); |
jb8414 | 0:f479e4f4db0e | 20 | virtual int available(); |
jb8414 | 0:f479e4f4db0e | 21 | virtual int read(); |
jb8414 | 0:f479e4f4db0e | 22 | virtual void flush(); |
jb8414 | 0:f479e4f4db0e | 23 | virtual void stop(); |
jb8414 | 0:f479e4f4db0e | 24 | virtual uint8_t connected(); |
jb8414 | 0:f479e4f4db0e | 25 | private: |
jb8414 | 0:f479e4f4db0e | 26 | virtual int read(uint8_t *buf, size_t size); |
mazgch | 11:5c71c2948812 | 27 | void _fillin(void); |
mazgch | 11:5c71c2948812 | 28 | uint8_t _inbuf[128]; |
mazgch | 11:5c71c2948812 | 29 | uint8_t _incnt; |
mazgch | 11:5c71c2948812 | 30 | void _flushout(void); |
mazgch | 11:5c71c2948812 | 31 | uint8_t _outbuf[128]; |
mazgch | 11:5c71c2948812 | 32 | uint8_t _outcnt; |
jb8414 | 0:f479e4f4db0e | 33 | TCPSocketConnection _sock; |
jb8414 | 0:f479e4f4db0e | 34 | }; |
jb8414 | 0:f479e4f4db0e | 35 | |
jb8414 | 0:f479e4f4db0e | 36 | #endif |