User Manual
AdafruitTCP
AdafruitTCP makes it easier to work with raw TCP sockets. You can open sockets -- including SSL based secure socket
connections -- and send and receive data using a few basic commands.
The class also and exposes two convenient (optional) callbacks:
Data Received Callback: Fires whenever incoming data is available (which can then be read via the .read() and
related commands)
Disconnect Callback: Fires whenever the TCP server cause you to disconnect
You're also free to 'poll' for incoming data and connection status, but these callbacks help keep your TCP code easy to
understand and more maintainable as your project grows in complexity.
TCP Socket API
The AdafruitTCP class includes the following functions:
Packet Buffering
The AdafruitTCP class includes the option to enable or disable packet buffering.
If packet buffering is enabled, outgoing data will be buffered until the buffer is full (~1500 bytes) or until .flush() is called
to manually force the buffered data to be sent.
If packet buffering is disabled, any write commands will send the data immediately, regardless of the packet or data
size. This ensure writes happen right away, but at the cost of slower overall throughput since data can't be grouped
together into larger packets.
// Misc Functions
void usePacketBuffering (bool enable);
void tlsRequireVerification (bool required);
uint32_t getHandle (void);
// Client API
virtual int connect (IPAddress ip, uint16_t port);
virtual int connect (const char * host, uint16_t port);
virtual int connectSSL (IPAddress ip, uint16_t port);
virtual int connectSSL (const char* host, uint16_t port);
virtual uint8_t connected (void);
virtual void stop (void);
// Stream API
virtual int read (void);
virtual int read (uint8_t * buf, size_t size);
virtual size_t write (uint8_t);
virtual size_t write (const uint8_t *content, size_t len);
virtual int available (void);
virtual int peek (void);
virtual void flush (void);
// Set callback handlers
void setReceivedCallback (tcpcallback_t fp);
void setDisconnectCallback (tcpcallback_t fp);
© Adafruit Industries https://learn.adafruit.com/introducing-the-adafruit-wiced-feather-wifi Page 73 of 202










