Hardware Reference
In-Depth Information
This function does not take any parameters and returns the number of bytes
waiting in the buffer.
This allows an Arduino to connect to a server and to exchange stream infor-
mation, but how exactly is that useful for your application? Almost all protocols
rely on an exchange of stream information, including HTTP, FTP, and other
common protocols.
Connecting to a Web Server
Web servers also stream data. Each connection is made to port 80 of the web
server and can be done in plaintext. After all, before graphical interfaces, all
the web was viewed as simple text.
To help as an example, I have uploaded a i le to my web server called hel-
loarduino.html. It is located at the following address:
If you open this in a web browser, you will be greeted by a simple sentence:
Hello, Arduino! To understand how an Arduino, and indeed any web browser
works, try to connect to the web server using telnet, a protocol used to connect
to a server using a text-oriented message. This utility is standard on Linux and
Mac OS systems, and can be run by opening a terminal and entering telnet
<IP> <port> as a command. IP is the IP address of the server you want to con-
nect to, and port is the port of the service you want to connect to. For a web
browser, this will be 80. For a Windows machine, a download is required. PuTTY
is a very nice, free application that lets you connect to services. It is available at
http://www.putty.org .
telnet packetfury.net 80
This program creates a connection to the specii ed host on the specii ed port.
Here, you connect to packetfury.net on port 80. Normally, a web server listens
to connections on port 80. You should be greeted with something that looks
like this:
jlangbridge@desknux:~/Downloads$ telnet packetfury.net 80
Connected to packetfury.net.
Escape character is '^]'.
After a short time, you will get another message:
HTTP/1.0 408 Request Time-out
Cache-Control: no-cache
Connection: close
Content-Type: text/html
Search WWH ::

Custom Search