ACKme Logo WiConnect Host Library- API Reference Guide
 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
WiconnectSocket.h
1 
29 #pragma once
30 
31 
32 #include "WiconnectTypes.h"
33 
34 namespace wiconnect
35 {
36 
44 {
45 public:
46  WiconnectSocket(int rxBufferLen = 0, void *rxBuffer = NULL, int txBufferLen = 0, void *txBuffer = NULL);
47  ~WiconnectSocket();
48 
49  WiconnectResult close();
50  WiconnectResult poll(bool *rxDataAvailablePtr, bool autoClose = false);
51  WiconnectResult write(const void* buffer, int length, bool flush = true);
52  WiconnectResult write(int length, bool flush = true);
53  WiconnectResult read(void* buffer, uint16_t maxLength, uint16_t *bytesRead);
54  WiconnectResult read(uint8_t **bufferPtr = NULL, uint16_t *bytesReadPtr = NULL);
55  WiconnectResult putc(uint8_t c, bool flush = false);
56  WiconnectResult puts(const char *s, bool flush = true);
57  WiconnectResult getc(uint8_t *c);
58  WiconnectResult printf(const char* format, ...);
59  WiconnectResult flushTxBuffer();
60  void clearRxBuffer();
61 
62  uint8_t *getTxBuffer();
63  int getTxBufferSize();
64  int getTxBufferBytesPending();
65  uint8_t *getRxBuffer();
66  int getRxBufferSize();
67  int getRxBufferBytesPending();
68 
69  bool isConnected();
70  SocketType getType();
71  const char* getHost();
72  uint16_t getLocalPort();
73  uint16_t getRemotePort();
74  uint8_t getHandle();
75 
76 protected:
77  bool connected;
78  SocketType type;
79  uint8_t handle;
80  char host[WICONNECT_MAX_HOST_SIZE];
81  uint16_t localPort;
82  uint16_t remotePort;
83  Wiconnect *wiconnect;
84  Buffer txBuffer;
85  Buffer rxBuffer;
86 
87  WiconnectResult init(uint8_t handle, SocketType type, const char *host, uint16_t remotePort, uint16_t localPort);
88 
89  WiconnectResult writeDataCallback(void *user, void *data, int maxReadSize, int *bytesRead);
90 
91  friend class SocketInterface;
92 };
93 
94 
95 }
SocketType
Socket type.
WiconnectResult
API Result code.
#define WICONNECT_MAX_HOST_SIZE
The maximum server string length.
Connection object to remote server.
The provides an interface for creating TCP/UDP/TLS/HTTP client sockets. A client socket connects to a...
The root WiConnect library class. This class inheriets all WiConnect functionality.