DOC PREVIEW
Penn CIT 597 - Basic Protocols

This preview shows page 1-2-3-4-5 out of 14 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Basic ProtocolsSocketsProtocolsTCP/IPHostnames and DNS serversDHCPURLsShowURL.javaAbout the ShowURL.java appletRunning the appletApplet resultsTryURL.java, ITryURL.java, IIThe EndJan 14, 2019Basic Protocols2SocketsSockets, or ports, are a very low level software construct that allows computers to talk to one anotherWhen you send information from one computer to another, you send it to a port on the receiving computerIf the computer is “listening” on that port, it receives the informationIn order for the computer to “make sense” of the information, it must know what protocol is being usedCommon port numbers are 80 (for web pages), 23 (for telnet) and 25 and 110 (for mail)Port numbers above 1024 are available for other kinds of communication between our programs3ProtocolsIn order for computers to communicate with one another, they must agree on a set of rules for who says what, when they say it, and what format they say it inThis set of rules is a protocolDifferent programs can use different protocolsProtocols may be in ASCII (characters) or in binarySome common protocols are HTTP (for web pages), FTP (for file transfer), and SMTP (Simple Mail Transfer Protocol)4TCP/IPThe Internet (and most other computer networks) are connected through TCP/IP networksTCP/IP is actually a combination of two protocols:IP, Internet Protocol, is used to move packets (chunks) of data from one place to anotherPlaces are specified by IP addresses: four single-byte (0..255) numbers separated by periodsExample: 192.168.1.1TCP, Transmission Control Protocol, ensures that all necessary packets are present, and puts them together in the correct orderTCP/IP forms a “wrapper” around data of any kindThe data uses its own protocol, for example, FTP5Hostnames and DNS serversThe “real” name of a computer on the internet is its four-byte IP addressPeople, however, don’t like to remember numbers, so we use hostnames insteadFor example, the hostname www.cis.upenn.edu is 158.130.12.9A DNS (Domain Name Server) is a computer that translates hostnames into IP addressesThink of it as like a phone book--names to useful numbersOf course, you have to know the IP address of the DNS in order to use it!You usually get two DNS numbers from your Internet Service Provider (ISP)6DHCPIf you have a web site, it must be hosted on a computer that is “permanently” on the WebThis computer must have a permanent IP addressThere aren’t enough IP addresses for the number of computers there are these daysIf you have no permanent web site, you can be given a temporary (dynamically allocated) IP address each time you connect to the WebSimilarly, if you have a home or office network, only one computer needs a permanent IP addressThe rest of the computers can be assigned internal, permanent IP addresses (not known to the rest of the world)They can also be assigned internal IP addresses dynamicallyDHCP (Dynamic Host Configuration Protocol) is a way of assigning temporary IP addresses as needed7URLsA URL, Uniform Resource Locater, defines a location on the WebA URL has up to five parts: http://www.xyz.com:80/ad/index.html#specialsProtocol -- http is used for Web pagesHostnamePort -- 80 is default for http requestsPath to a given pageAnchor -- a location within the page8ShowURL.javaimport java.net.*; // Gittleman, Example 2.2, pp. 67-68import java.applet.Applet;public class ShowURL extends Applet { public void init() { try { URL url = new URL(getParameter("url")); getAppletContext().showDocument(url); } catch(MalformedURLException e) { e.printStackTrace(); } }}9About the ShowURL.java appletimport java.net.*;This is the package that defines sockets, URLs, etc.URL url = new URL(getParameter("url"));Constructs a URL object from a text stringgetAppletContext()An AppletContext describes the document containing this applet and the other applets in the same documentshowDocument(url)Replaces the Web page currently being viewed with the given URLcatch(MalformedURLException e)This exception is thrown if the given String cannot be parsed by newURL(S tring)10Running the applet12311Applet resultsIf the applet is run using appletviewer, you get an applet, but it’s blankUnless, that is, the page you go to has a applet on itIf the applet is run using a browser,First, a web page appears, with a gray rectangle for the applet (which is just starting up)Then the initial web page is replaced by the web page specified by the URLYou are now in your regular browser, just as if you had typed the URL into itThis applet does not work for me in Firefox!Security issue?12TryURL.java, IShowURL.java is an applet; it runs in a browser, gets a web page, and displays it in that browserTryURL.java is an application; it runs standalone, gets a web page, and displays the HTML that it gotBasic structure:import java.net.*;import java.io.*;public class TryURL { public static void main(String[] args) { try { ...important code goes here.... } catch (Exception e) { ... } }}13TryURL.java, IIBufferedReader input;String line;URL url = new URL( "http://www.cis.upenn.edu/~matuszek/cit597-2004");input = new BufferedReader( new InputStreamReader(url.openStream()));line = input.readLine();while (line != null) { System.out.println(line); line = input.readLine();}input.close();14The


View Full Document

Penn CIT 597 - Basic Protocols

Documents in this Course
DOM

DOM

21 pages

More DOM

More DOM

11 pages

Rails

Rails

33 pages

DOM

DOM

21 pages

RELAX NG

RELAX NG

31 pages

RELAX NG

RELAX NG

31 pages

RELAX NG

RELAX NG

31 pages

RELAX NG

RELAX NG

31 pages

Rake

Rake

12 pages

Ruby

Ruby

58 pages

DOM

DOM

21 pages

Tomcat

Tomcat

16 pages

DOM

DOM

21 pages

Servlets

Servlets

29 pages

Logging

Logging

17 pages

Html

Html

27 pages

DOM

DOM

22 pages

RELAX NG

RELAX NG

30 pages

Servlets

Servlets

28 pages

XHTML

XHTML

13 pages

DOM

DOM

21 pages

DOM

DOM

21 pages

Servlets

Servlets

26 pages

More CSS

More CSS

18 pages

Servlets

Servlets

29 pages

Logging

Logging

17 pages

Load more
Download Basic Protocols
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Basic Protocols and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Basic Protocols 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?