Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

8. Connecting to the Internet > Coding the Server

Coding the Server

Since you’re using the Netduino Plus’s built-in LED for this demo, there’s no need to wire up any components. This means you can move on to the code.

Create a new Netduino Plus app. Make sure that you select “Netduino Plus” instead of “Netduino,” so that the networking features are available to your app.

Inside your Main routine, start by typing in the following code:

// set up the LED and turn it off by default
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

As before, this configures the onboard LED. You’ll turn this on and off via web requests.

Next, define a port for your Netduino to listen on. Port 80 is the default web server port, so use it here. If you want to connect to your Netduino over the Internet you may need to use a higher port number such as 8080—or use your router’s port forwarding feature—so that you can access your Netduino through a firewall:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint