Internet Programming 2nd Term PDF
Document Details
Uploaded by Deleted User
Tags
Summary
This document explains the concepts of client/server networks, different types of networks like WAN, MAN, LAN, HAN and PAN, their benefits, and how they are structured. It also discusses the role of various components such as file servers and web servers within these networks.
Full Transcript
**Understanding Networks and the Internet** The **Internet** -- The international network known as the *internet* consists of hundreds of thousands of smaller networks linking educational, commercial, nonprofit, and military organizations, as well as individuals. Central to this arrangement is the...
**Understanding Networks and the Internet** The **Internet** -- The international network known as the *internet* consists of hundreds of thousands of smaller networks linking educational, commercial, nonprofit, and military organizations, as well as individuals. Central to this arrangement is the client/server network. A **client computer** is a computer requesting data or services. A **server, or host computer**, is a central computer supplying data or services requested of it. When the client computer's request -- for example, for information on various airline flights and prices -- gets to a server computer, that computer sends the information back to the client computer. **Network** -- A network, or communications network, is a system of interconnected computers, telephones, or other communications devices that can communicate with one another and share applications and data. The tying together of so many communication devices in so many ways is changing the world we live in. **Benefits of a Network** - Sharing of Peripheral Devices - Sharing of Programs and Data - Better Communications - Security of Information - Access to Databases (databases- compilation of data) **Types of Networks** - **WAN (Wide Area Network)** - A communication network that covers a wide geographic area, such as a country or the world. Most long-distance and regional telephone companies are WANs. A WAN may use a combination of satellites, fiber-optic cable, microwave, and copper-wire connections and link a variety of computers, from mainframes to terminals. - **MAN (Metropolitan Area Network)** - A communications network covering a city or a suburb. The purpose of a MAN is often to bypass local telephone companies when accessing long distance services. Many cellphone systems are MANs. - **LAN (Local Area Network)** - Or local net, connects computers and devices in a limited geographic area, such as one office, one building, or a group of buildings close together. LANs are the basis for most office networks. The LANs of different offices on a university campus may also be linked together into a so-called campus-area network. - **HAN (Home Area Network)** - Uses wired, cable, or wireless connections to link a household's digital devices - not only multiple computers, printers, and storage devices but also VCRs, DVDs, televisions, fax machines, videogame machines, and home security systems.4 (A variant of the HAN is the GAN -- the garden area network -- which can be used to link watering systems, outdoor lights, and alarm systems.) - **PAN (Personal Area Network)** - Slightly different from a HAN because it doesn't use wires or cables, a personal area network (PAN), or wireless personal area network (WPAN), uses short -- range wireless technology to connect an individual's personal electronics, such as cellphone, PDA, MP3 player, notebook PC, and printer. PANs are made possible with such inexpensive, short -- range wireless technologies as Bluetooth, ultra-wideband, and wireless USB, which have a range of 30 feet or so, as we will describe. - **HAN (Home Automation Network)** - Relies on very inexpensive, very short-range, low-power wireless technology in the under-200-Kbps range to link switches and sensors around the house. Such networks, which use wireless standards such as Insteon, ZigBee, and Z-Wave, as we will describe, run on inexpensive AA batteries and use wireless remotes, in wall touch screens, and PDAs, along with special software, to control lights and switches, thermostats and furnaces, smoke alarms and outdoor floodlights. **How Networks are Structured** - **Client/Server Networks**. A client/server network consists of clients, which are microcomputers that request data, and servers, which are computers used to supply data. The server is a powerful microcomputer that manages shared devices, such as laser printers. It runs server software for applications such as email and web browsing. Different servers may be used to manage different tasks. - A **file server** is a computer that acts like a disk drive, storing the programs and data files shared by users on a LAN. - A **database server** is a computer in a LAN that stores data but doesn\'t store programs. - A **print server** controls one or more printers and stores the print-image output from all the microcomputers on the system. - **Web servers** contain web pages that can be viewed using a browser. - **Mail servers** manage email. - **Peer-to-Peer Networks** - In a peer-to-peer (P2P) network, all microcomputers on the network communicate directly with one another without relying on a server Every computer can share files and peripherals with all other computers on the network, given that all are granted access privileges. - Peer-to-peer networks are less expensive than client/server networks and work effectively for up to 25 computers. Beyond that, they slow down under heavy use. They are appropriate for small networks, such as home networks **Components of a Network** - **Hosts & Nodes** - A client/server network has a host computer, a mainframe or midsize central computer that controls the network. The other devices on the network are called nodes. A node is any device that is attached to a network- for example, a microcomputer, terminal, storage device, or printer. For instance, a device called a wireless access point (WAP) when attached to a network essentially extends the range of the network by offering several wireless nodes, enabling you, say, to wirelessly connect a computer in a back bedroom to a network at the front of the house. - **Packets** - Electronic messages are sent as packets. A packet is a fixed-length block of data for transmission. A sending computer breaks an electronic message apart into packets, each of which typically contains 1,000-1,500 bytes. The various packets are sent through a communications network-often using different (and most expedient) routes, at different speeds, and sandwiched in between packets from other messages. Once the packets arrive at their destination, the receiving computer reassembles them into proper sequence to complete the message. - **Protocols** - A protocol, or communications protocol, is a set of conventions governing the exchange of data between hardware and/or software components in a communications network. Every device connected to a network has an internet protocol (IP) address so that other computers on the network can properly route data to that address. Sending and receiving devices must follow the same set of protocols. - **Wired and/or Wireless Connections** - Networks use a wired or wireless connection system. Wired connections may be twisted-pair wiring, coaxial cable, or fiber-optic cable, and wireless connections may be infrared, microwave (such as Bluetooth), broadcast radio (such as Wi-Fi), or satellite, as we describe shortly. **Network Linking devices** - **Hubs --** In general, a hub is the central part of a wheel where the spokes come together. In computer terminology, a hub is a common connection point for devices in a network -- a place of convergence where data arrives from one or more directions and is forwarded out in one or more other directions. - **Switches -** A switch is a device that connects computers to a network. Unlike a hub, it sends messages only to a computer that is the intended recipient. A switch is a full-duplex device, meaning data is transmitted back and forth at the same time, which improves the performance of the network. Switches allow each component full use of the bandwidth. Switches are used only in certain configurations, hubs and switches can be used in combination. - **Gateways** - A gateway is an interface permitting communication between dissimilar networks-for instance, between a LAN and a WAN or between two LANs based on different network operating systems or different layouts. Gateways can be hardware, software, or a combination of the two. - **Routers -** A router is a special computer that directs communicating messages when several networks are connected together. High- speed routers can serve as part of the internet backbone, or transmission path, handling the major data traffic. **Wired Communication Media** - It used to be that two-way individual communications were accomplished mainly in two ways. They were carried by the medium of (1) a telephone wire or (2) a wireless method such as shortwave radio. Today there are many kinds of communications media, although they are still wired or wireless. Communications media, or communications channels, carry signals over a communications path, the route between two or more communications media devices. The speed, or data transfer rate, at which transmission occurs-and how much data can be carried by a signal-depends on the media and the type of signal. **Wired Communication (Wires and Cables)** **Twisted-Pair Wire** - The telephone line that runs from your house to the pole outside, or underground, is probably twisted-pair wire. Twisted-pair wire consists of two strands of insulated copper wire, twisted around each other. This twisted-pair configuration (compared to straight wire) somewhat reduces interference (called \"crosstalk\") from electrical fields. **Coaxial Cable** - Coaxial cable, commonly called \"co-ax,\" is a high-frequency transmission cable that consists of insulated copper wire wrapped in a solid or braided metal shield and then in an external plastic cover. Co-ax is widely used for cable television and cable internet connections. Thanks to the extra insulation, coaxial cable is much better than twisted-pair wiring at resisting noise **Fiber-Optic Cable** - A fiber-optic cable consists of dozens or hundreds of thin strands of glass or plastic that transmit pulsating beams of light rather than electricity. These strands, each as thin as a human hair, can transmit up to about 2 billion pulses per second (2 gigabits); each \"on\" pulse represents 1 bit. When bundled together, fiber-optic strands in a cable 0.12 inch thick can support a quarter- to a half-million voice conversations at the same time. **Wireless Communication Media** Wireless connection has become increasingly popular, with 56% of Americans reporting in 2009 they got on the internet through wireless, many (39%) through a laptop, others (32%) through a mobile device, such as a cellphone. Cellphones are only one kind of wireless communication. We consider (1) the electromagnetic spectrum, (2) the five types of long-distance wireless communications media, (3) long-distance wireless, and (4) short- distance wireless. **Electromagnetic Spectrum, Radio Frequency & Bandwidth** **Electromagnetic Spectrum** **Bandwidth -** The bandwidth is the range, or band, of frequencies that a transmission medium can carry in a given period of time. The wider a medium's bandwidth, the more frequencies it can use to transmit data and thus the faster the transmission. There are two general classes of bandwidth- narrow and broad-which can be expressed in hertz but also in bits per second (bps) Different Wireless Cellular Transmission - 1G (First Generation) Analog Services - 2G (Second Generation) Wireless Services - 3G (Third Generation) Wireless Digital Services - 4G (Fourth Generation) Wireless Digital Services - Wimax - 5G (Fifth Generation) World Wide Web (WWW) The internet and the World Wide Web, as we have said, are not the same. The internet is a massive network of networks, connecting millions of computers via protocols, hardware, and communications channels. It is the infrastructure that supports not only the web but also other communications systems such as email, instant messaging, newsgroups, and other activities that we\'ll discuss. The part of the internet called the web is a multimedia-based technology that enables you to access more than just text. That is, you can also download art, audio, video, and animation and engage in Interactive games. It is a collection of internet sites that offer text and graphics and sound and animation resources through the hypertext transfer protocol. Key Terminologies - Protocol-is the language used by computers to communicate with each other. - HTTP-Hypertext Transfer Protocol is a protocol used to request and transmit files, especially Web pages and Web pages components. - URL-Uniform Resource Locator is an address widget that identifies a document or resource on the World Wide Web. Example: Types of High-Level/Top-Level Domain Name.COM -- Private Company/ Personal Address.ORG -- Non-Government Organization.EDU -- Educational Institution.NET -- Internet Service Provider.GOV -- Government Office.MIL -- Military Internet Country code.jp -- Japan.uk -- United Kingdom.ph -- Philippines.us -- United States.au -- Australia.ca -- Canada **Programming** is the process of creating a set of instructions that tell a computer how to perform a task. Programming can be done using a variety of computer programming languages, such as JavaScript, Python, and C++. Coding: Writing Programming: Action **The Language of Code** - Computers only understand machine code **Machine code**, also known as machine language, is the elemental language of computers. It is read by the computer\'s central processing unit (CPU), is composed of digital binary numbers and looks like a very long sequence of zeros and ones. **Programming Languages** A programming language is any set of rules that converts strings, or graphical program elements in the case of visual programming languages, to various kinds of machine code output. Programmer to Translator (language understood by computer) to Computer **Each language is unique in how they operate.** - Java and Python - General Purpose languages (used in creating a variety of software, word excels to computer games) - HTML/CSS -- Specific Purpose languages (Used for web page design: HTML and CSS) **Each language has levels.** - Low-level programming language - Assembly or C - High-level programming language - Java or Python **Coding** How do we send instructions to the computer? **Integrated Development Environments (IDE)** An integrated development environment is a software suite that consolidates basic tools required to write and test software. In addition to a place to write code, IDE\'s also include: Built in Error-checking Auto-fill for frequently used words Project Hierarchy (you can see recent codes, latest to oldest) Interface (where you code, input code) **Each language has its own set of rules** that must be followed within the IDE. SYNTAX (how u construct sentences in the programming languages) - How to type a certain function - How to set up functions - Each programming language has its unique syntax Console - used to interact with the computer. It is used to output text using code. **INTRODUCTION TO JAVA** Java was created in 1991 by James Gosling et al. of Sun Microsystems. Initially called Oak, in honor of the tree outside Gosling\'s window, its name was changed to Java because there was already a language called Oak. The original motivation for Java was the need for platform independent language that could be embedded in various consumer electronic products like toasters and refrigerators. One of the first projects developed using Java was a personal hand-held remote control named Star 7. Motivation: international language At about the same time, the World Wide Web and the Internet were gaining popularity. Gosling et. al. realized that Java could be used for Internet programming. (First use of Java programming: Internet programming (you cannot play YouTube (or other websites) if a computer has no java flash player) **WHAT IS JAVA TECHNOLOGY?** - A Programming Language As a programming language, Java can create all kinds of applications that you could create using any conventional programming language. - A Development Environment As a development environment, Java technology provides you with a large suite of tools. a compiler, an interpreter, a documentation generator, a class file packaging tool, and so on. - An Application Environment Java technology applications are typically general- purpose programs that run on any machine where the Java runtime environment (JRE) is installed. General purpose: programming language - A Deployment Environment There are two main deployment environments: First, the JRE supplied by the Java 2 Software Development Kit (SDK) contains the complete set of class files for all the Java technology packages, which includes basic language classes, GUI component classes, and so on. The other main deployment environment is on your web browser. Most commercial browsers supply a Java technology interpreter and runtime environment. **Some features of JAVA** - The Java Virtual Machine The Java Virtual Machine is an imaginary machine that is implemented by emulating software on a real machine. The JVM provides the hardware platform specifications to which you compile all Java technology code. This specification enables the Java software to be platform-independent because the compilation is done for a generic machine known as the JVM. (separated to the system, (no change will happen on your system when working on the java virtual machine) - Garbage Collection Many programming languages allows a programmer to allocate memory during runtime. However, after using that allocated memory, there should be a way to deallocate that memory block in order for other programs to use it again. In C, C++ and other languages the programmer is responsible for this. This can be difficult at times since there can be instances wherein the programmers forget to deallocate memory and therefor result to what we call memory leaks. (Automatic removal of data, unlike others, need to manually delete all memory to remove unwanted files. - A bytecode is a special machine language that can be understood by the Java Virtual Machine (JVM). The bytecode is independent of any particular computer hardware, so any computer with a Java interpreter can execute the compiled Java program, no matter what type of computer the program was compiled on. Phases of JAVA program Editor \> Hello Java \> Java compiler \> Hello class \> Java interpreter Eclipse: \\t (tab) \\n (next line) \\\\ or \\\* \*\\ (comments) - Show the use of their codes (no effect on the code) - Can be use for debugging or checking for errors **Java Statements and Blocks** A **statement** is one or more lines of code terminated by a semicolon. A **block** is one or more statements bounded by an opening and closing curly braces that groups the statements as one unit. Block statements can be nested indefinitely. Any amount of white space is allowed. **Java Identifiers** - Identifiers are tokens that represent names of variables, methods, classes, etc. Examples of identifiers are: Hello, main, System, out. - Java identifiers are case-sensitive. - Identifiers must begin with either a letter, an underscore \"\", or a dollar sign \"\$\" (not recommended). Letters may be lower or upper case. Subsequent characters may use numbers 0 to 9. - Identifiers cannot use Java keywords like class, public, void, etc. We will discuss more about Java keywords later. - Can only be used with their intended purpose. Keyboards: **Java Literals** - Any constant that can be assigned to the variable. - Literals are tokens that do not change or are constant. The different types of literals in Java are: Integer Literals, Floating-Point Literals, Boolean Literals, Character Literals and String Literals. **Integer Literals** - Integer literals come in different formats: decimal (base 10), hexadecimal (base 16), and octal (base 8). In using integer literals in our program, we have to follow some special notations. - For decimal numbers, we have no special notations. We just write a decimal number as it is. For hexadecimal numbers, it should be preceded by \"Ox\" or \"OX\". For octals, they are preceded by \"0\". - Integer literals default to the data type int **Floating Point Literals** - Floating point literals represent decimals with fractional parts. An example is 3 1415 Floating point literals can be expressed in standard or scientific notations. -For example, 583.45 is in standard notation, while 5.8345e2 is in scientific notation. **Boolean Literals** - Boolean literals have only two values, true or false. - Data type Boolean **Character Literals** - Character Literals represent single Unicode characters. A Unicode character is a 16-bit character set that replaces the 8-bit ASCII character set. Unicode allows the inclusion of symbols and special characters from other languages. **String Literals** - String literals represent multiple characters and are enclosed by double quotes. Variables - A variable is an item of data used to store state of objects. - To declare a variable is as follows, \ \ \[=initial value\]; //datatype variableName= initialValue; (syntax of variable) Data type: integer, Boolean INTEGER int myInt=10; (myInt = container with the type) System.out.println(myInt); Result: 10 FLOAT Double myFloat =3.98; System.out.println(myFloat); STRING String myString ="k";