Learn R Programming

getip (version 0.1-4)

hostname2ip: hostname2ip

Description

Converts a hostname (or vector of hostnames) to

Usage

hostname2ip(hosts)

Value

A list of vectors of IP's. Each IP is stored as a string.

Arguments

hosts

A vector of hostnames as strings (or just one).

Details

Only IPv4 addresses will be returned. If only IPv6 addresses exist (and if that is the case, allow me to be the first to greet you, person from the distant future) then NA is returned for that hostname.

The function uses getaddrinfo() on *NIX systems, and gethostbyname() on Windows.

Examples

Run this code
library(getip)

# \donttest{
hosts = c("www.google.com", "localhost", "www.yahoo.com")
hostname2ip(hosts)
# }

Run the code above in your browser using DataLab