Chapter 9. Hello Pachube (Sockets Version)

In this chapter, I will present a version of a complete Pachube client that uses the Socket API. It demonstrates that this low-level API is a viable alternative, especially for “fire and forget” requests.

PachubeClient

HelloPachubeSockets (Example 9-1) performs some initializations in its Main method, enters an endless loop in which it waits until it is time for the next measurement, performs the measurement, and then sends the result to Pachube. This is repeated every 20 seconds like in the original HelloPachube program.

Example 9-1. HelloPachubeSockets
using System; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; ...

Get Getting Started with the Internet of Things now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.