![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Perl CGl Programming: No experience required.
Using TCP/IP and the hosts fileThe Sambar server runs on Windows 95 and NT. However, it also requires that TCP/IP, the Internet communication protocol we discussed in Skill 1, is running on its host computer. If youre not familiar with the term TCP/IP, you probably dont have anything to worry about because even the lowliest dial-up connection to an Internet service provider requires it. So if you can get out to the World Wide Web, you certainly have TCP/IP running on your computer already. You can take advantage of a handy TCP/IP feature to use any Web browser to connect directly with the Sambar server on your computer: the hosts file. When you type a URL into your Web browser it is usually in the form of an Internet domain address such as www.WebSite.com. But the descriptive address is meaningless to the software that routes information around the Internet. The address has to be translated into an IP address such as 198.169.20.0 before anything can be done with it. Normally, the browser gets that information from a Domain Name Server (DNS), which runs on the ISPs computer. In a very simple sense, the DNS is a table of domain names and IP addresses; the browser gives it a name, and the DNS returns the numeric address. If your computer isnt hooked up to your ISP, the Web browser has no way to resolve domain names. However, in the TCP/IP scheme of things, the DNS is the second place to look for addresses. The first is the hosts file, which is right on your computer (see Figure 2.12).
The hosts file is a plain text file; you can call it up with any text editor, such as Notepad. On Windows 95, the file is in the \Windows directory. On Windows NT, you will find it in \winnt\system32\drivers\etc. As in Perl, lines in the hosts file that begin with the pound sign (#) are comments. Notice in Figure 2.13 that the only uncommented line in the file is the last one: 127.0.0.1 localhost The line illustrates how IP addresses are associated with domain names in the hosts file. This particular IP address (127.0.0.1) is special, however. It defines a loopback address that always points to the local computer. It is usually used for testing and, in fact, thats how you will use it. You should ensure that you actually have a hosts file by using Explorer to poke into the appropriate directory for your operating system. If you dont see the file, its easy enough to create it by following these steps:
Now, if the Sambar server is running, you can point your Web browser to http://localhost and the servers default home page will pop up. By the way, although you should have one entry in the hosts file that associates 127.0.0.1 with the name localhost, youre not stuck with that one name. Any domain name that you put on the same line will be linked with the IP address, so you could type: 127.0.0.1 localhost www.alfredpacker.com mydomain.com Now www.alfredpacker.com and mydomain.com point to the same address as localhost and you can use them as URLs in your Web browser.
Running the Sambar ServerThe default Sambar Web server installation will put a shortcut to the software in your Programs menu. All you have to do to start the server is open the Programs menu and click the shortcut. You will notice first of all that nothing seems to happen. Not to worrythe server runs in the background. The only evidence of its presence is a small icon on the right side of the Taskbar.
Moving On Youve learned a bit about setting up your Web server in this skill, and you have begun your acquaintance with the Perl-HTML connection. You have also learned about using subroutines in Perl to produce reusable code. In Skill 3, youll be introduced to the Common Gateway Interface and the environment variables that you can use to hook the Web server to a Perl script. Youll learn several new and useful concepts in Perl, as well. Are You Experienced?Now you can
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. |