Hardware Reference
In-Depth Information
(or a domain name that will later be converted to an IP address) and a port. It
is not something physical; it is represented only in software.
Imagine you want to create a web server. You install the required software, and
your computer is connected to the Internet. You are now ready to go. Computers
can now connect to your server and view your web pages. Now imagine you
want to create an FTP server on the same computer as the web server. How
can you do that? How can the server understand what the client wants? This
is where ports come in.
A server program creates a port, and a client connects to that port. Some ports
are standard; others are created randomly. A web server will always be opened
on port 80, and your Internet browser will automatically attempt to connect to
port 80 when you add an Internet address beginning with http. When using
secure HTTP, the browser connects to port 443. It is also possible to tell the
browser to which port you want to connect by specifying the port; just add a
colon and the port number at the end.
Port numbers range from 1 to 65535. Port numbers 1024 and below are reserved,
and most computers require administrative rights to open a low port. High
ports, from 1025 upward, can be opened with non-administrator programs.
When playing a multiplayer game, the server almost certainly uses a high port,
and clients know which port to connect to. (For example, Minecraft uses port
25565 by default.)
Ethernet on Arduino
Most Arduinos do not come with Ethernet support. The Arduino Ethernet is an
exception; it remains close to the Arduino Uno design and has an Ethernet port
with optional PoE support. The Arduino Yún also has an Ethernet connector,
but the Arduino Yún is two machines in one. An Arduino “talks” to an Atheros
processor, running a Linux distribution that handles network connectivity. The
Arduino Tre has a similar interface; an Arduino “talks” to a Cortex-A8 micro-
processor that has an Ethernet connector. This chapter covers only Arduino
boards with an Ethernet chip addressed directly by an Arduino-compatible
microcontroller: the Arduino Ethernet and any Arduino with an Ethernet shield.
Importing the Ethernet Library
To import the Ethernet library, you can use the Arduino IDE. Go to Sketch
Import Library
Ethernet. Doing so imports a relatively large amount of libraries:
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <Dhcp.h>
 
Search WWH ::




Custom Search