Book Image

R Object-oriented Programming

By : Kelly Black
Book Image

R Object-oriented Programming

By: Kelly Black

Overview of this book

Table of Contents (19 chapters)
R Object-oriented Programming
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
4
Calculating Probabilities and Random Numbers
Package Management
Index

Network options


Another way to read information is through a network connection using sockets. The methods available to manipulate sockets will be briefly explored in this section. We first explore the high level socket commands that make use of the socketConnection command to create a connector. Next, some of the more basic options are briefly stated. This is an advanced topic beyond the scope of this book, but it is provided here as a matter of completeness.

Opening a socket

The socketConnection command will create a network connection to a given host using a port number. The command returns a connector that can be treated the same as a file connector. In the following example, a connection is opened to the waterdata.usgs.gov website using the standard HTTP port, 80. It then sends the HTTP header necessary to request the data for the daily flow rates for the South Colton station on the Raquette River in northern New York:

> usgs <- socketConnection(host = "waterdata.usgs.gov",80)
...