img
.
String str = (args.length == 0 ? "osborne.com" : args[0]) + "\n";
// Convert to bytes.
byte buf[] = str.getBytes();
// Send request.
out.write(buf);
// Read and display response.
while ((c = in.read()) != -1) {
System.out.print((char) c);
}
s.close();
}
}
If, for example, you obtained information about osborne.com, you'd get something similar
to the following:
Whois Server Version 1.3
Domain names in the .com, .net, and .org domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.
Domain Name: OSBORNE.COM
Registrar: NETWORK SOLUTIONS, INC.
Whois Server: whois.networksolutions.com
Referral URL: http://www.networksolutions.com
Name Server: NS1.EPPG.COM
Name Server: NS2.EPPG.COM
.
.
.
Here is how the program works. First, a Socket is constructed that specifies the host
name "internic.net" and the port number 43. Internic.net is the InterNIC web site that
handles whois requests. Port 43 is the whois port. Next, both input and output streams are
opened on the socket. Then, a string is constructed that contains the name of the web site you
want to obtain information about. In this case, if no web site is specified on the command
line, then "osborne.com" is used. The string is converted into a byte array and then sent out of
the socket. The response is read by inputting from the socket, and the results are displayed.
URL
The preceding example was rather obscure because the modern Internet is not about the
older protocols such as whois, finger, and FTP. It is about WWW, the World Wide Web. The
Web is a loose collection of higher-level protocols and file formats, all unified in a web
browser. One of the most important aspects of the Web is that Tim Berners-Lee devised a
scaleable way to locate all of the resources of the Net. Once you can reliably name anything
and everything, it becomes a very powerful paradigm. The Uniform Resource Locator
(URL) does exactly that.
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home