lec14 - COMP201 Java Programming Part III: Advanced...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
COMP201 Java Programming Part III: Advanced Features Topic 14: Networking Volume II,Chapter 3
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COMP201 Topic 14 / Slide 2 Outline Networking basics IP addresses, ports, protocols, client-server interaction Socket-level programming Writing a client Writing a server URL connections and web servers Retrieving information Sending information
Background image of page 2
COMP201 Topic 14 / Slide 3 Networking Basics Internet protocol (IP) address Every host on Internet has a unique IP address 143.89.40.46, 203.184.197.198 203.184.197.196, 203.184.197.197, 127.0.0.1 More convenient to refer to using hostname string cs.ust.hk, tom.com, localhost Domain Naming Service (DNS) maps names to numbers One hostname can correspond to multiple internet addresses: tom.com: 203.184.197.196,
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COMP201 Topic 14 / Slide 4 java.net.InetAddress class converts between hostnames and internet addresses InetAddress tm = InetAddress.getByName (“tom.com"); InetAddress tm= InetAddress.getByName (“localhost"); //127.0.0.1 InetAddress tm = InetAddress.getLocalHost (); Can get array of addresses (if more than one) InetAddress[] addrs; addrs=InetAddress. getAllByName (“tom.com"); for ( int i = 0; i < addr.length; i++) System.out.println(addrs[i]. getHostAddress ()); InetAddressTest.java Networking Basics
Background image of page 4
COMP201 Topic 14 / Slide 5 Ports A port identifies a service within a host Many different services can be running on the host Many standard port numbers are pre-assigned time of day 13 , ftp 21 , telnet 23 , smtp 25 , finger 79 , http 80 see /etc/services on workstation for list of all assigned ports IP address + port number = "phone number“ for service Networking Basics
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COMP201 Topic 14 / Slide 6 protocols : rules that facilitate communications between machines Time of day just reports time, ftp has put/get commands, etc. Protocols must be standardized and documented So machines can reliably work with one another TCP (Transmission Control Protocol) vs UDP (User Datagram Protocol, good for, e.g., video delivery) Networking Basics
Background image of page 6
COMP201 Topic 14 / Slide 7 Client-Server interaction Communication between hosts is two-way, but usually the two hosts take different roles Server waits for client to make request Server registered on a known port with the host ("public phone number") Usually running in endless loop Listens for incoming client connections Networking Basics
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COMP201 Topic 14 / Slide 8 Client "calls" server to start a conversation Client making calls uses hostname/IP address and port number Sends request and waits for response Standard services always running ftp, http, smtp, etc. server running on host using expected port Server offers shared resource (information,database, files, printer, compute power) to clients Networking Basics
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/14/2010 for the course COMP COMP 201 taught by Professor Nil during the Spring '02 term at HKUST.

Page1 / 26

lec14 - COMP201 Java Programming Part III: Advanced...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online