Network Programming. Java provides easy-to-use classes for network programming. These classes integrate nicely with the rest of the language.



Similar documents
Division of Informatics, University of Edinburgh

Learning Outcomes. Networking. Sockets. TCP/IP Networks. Hostnames and DNS TCP/IP

Application Development with TCP/IP. Brian S. Mitchell Drexel University

Lesson: All About Sockets

Question1-part2 What undesirable consequences might there be in having too long a DNS cache entry lifetime?

Network/Socket Programming in Java. Rajkumar Buyya

Network Communication

Socket Programming in Java

Java Network. Slides prepared by : Farzana Rahman

Building a Multi-Threaded Web Server

Introduction to Java. Module 12: Networking (Java Sockets) Prepared by Costantinos Costa for EPL 233. ΕΠΛ233 Αντικειμενοστρεφής Προγραμματισμός 1

Assignment 4 Solutions

Mail User Agent Project

Remote login (Telnet):

File class in Java. Scanner reminder. Files 10/19/2012. File Input and Output (Savitch, Chapter 10)

The Application Layer. CS158a Chris Pollett May 9, 2007.

Socket programming. Complement for the programming assignment INFO-0010

Object-Oriented Programming in Java

1 Introduction: Network Applications

Creating a Simple, Multithreaded Chat System with Java

NETWORK PROGRAMMING IN JAVA USING SOCKETS

The Java I/O System. Binary I/O streams (ascii, 8 bits) The decorator design pattern Character I/O streams (Unicode, 16 bits)

Agenda. Network Programming and Java Sockets. Introduction. Internet Applications Serving Local and Remote Users

Network Technologies

Java Network Programming. The java.net package contains the Socket class. This class speaks TCP (connection-oriented protocol).

Data Communication & Networks G

FTP client Selection and Programming

Chapter 20 Streams and Binary Input/Output. Big Java Early Objects by Cay Horstmann Copyright 2014 by John Wiley & Sons. All rights reserved.

String sentence = new String(receivePacket.getData()); InetAddress IPAddress = receivepacket.getaddress(); int port = receivepacket.

INPUT AND OUTPUT STREAMS

public static void main(string[] args) { System.out.println("hello, world"); } }

Transport layer protocols. Message destination: Socket +Port. Asynchronous vs. Synchronous. Operations of Request-Reply. Sockets

Introduction to Java

CISC 4700 L01 Network & Client- Server Programming Spring Harold, Chapter 8: Sockets for Clients

D06 PROGRAMMING with JAVA

Java Programming: Sockets in Java

Chapter 2 Application Layer. Lecture 5 FTP, Mail. Computer Networking: A Top Down Approach

Domain Name System (DNS) Omer F. Rana. Networks and Data Communications 1

CS 121 Intro to Programming:Java - Lecture 11 Announcements

Chulalongkorn University International School of Engineering Department of Computer Engineering Computer Programming Lab.

CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O

Applications and Services. DNS (Domain Name System)

File I/O - Chapter 10. Many Stream Classes. Text Files vs Binary Files

Internet Technologies. World Wide Web (WWW) Proxy Server Network Address Translator (NAT)

CS43: Computer Networks . Kevin Webb Swarthmore College September 24, 2015

The Application Layer: DNS

AVRO - SERIALIZATION

Socket-based Network Communication in J2SE and J2ME

The difference between TCP/IP, UDP/IP and Multicast sockets. How servers and clients communicate over sockets

Network Programming using sockets

CPSC Network Programming. , FTP, and NAT.

What is an I/O Stream?

Communicating with a Barco projector over network. Technical note

First Workshop on Open Source and Internet Technology for Scientific Environment: with case studies from Environmental Monitoring

13 File Output and Input

Limi Kalita / (IJCSIT) International Journal of Computer Science and Information Technologies, Vol. 5 (3), 2014, Socket Programming

CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus

Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit.

Simple Mail Transfer Protocol

CS 1302 Ch 19, Binary I/O

1. When will an IP process drop a datagram? 2. When will an IP process fragment a datagram? 3. When will a TCP process drop a segment?

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius

TCP/IP and the Internet

JAVA Program For Processing SMS Messages

DNS: Domain Names. DNS: Domain Name System. DNS: Root name servers. DNS name servers

Sample CSE8A midterm Multiple Choice (circle one)

Evolution of the WWW. Communication in the WWW. WWW, HTML, URL and HTTP. HTTP Abstract Message Format. The Client/Server model is used:

Files and input/output streams

Chapter 27 Hypertext Transfer Protocol

Internet Technology 2/13/2013

Cross-platform TCP/IP Socket Programming in REXX

Web. Services. Web Technologies. Today. Web. Technologies. Internet WWW. Protocols TCP/IP HTTP. Apache. Next Time. Lecture # Apache.

File Transfer Protocol (FTP) Chuan-Ming Liu Computer Science and Information Engineering National Taipei University of Technology Fall 2007, TAIWAN

Linux MPS Firewall Supplement

TCP/IP Networking An Example

JAVA - FILES AND I/O

Evolution of the WWW. Communication in the WWW. WWW, HTML, URL and HTTP. HTTP - Message Format. The Client/Server model is used:

WRITING DATA TO A BINARY FILE

Intel Retail Client Manager Audience Analytics

SSC - Communication and Networking Java Socket Programming (II)

Cape Girardeau Career Center CISCO Networking Academy Bill Link, Instructor. 2.,,,, and are key services that ISPs can provide to all customers.

Course Overview: Learn the essential skills needed to set up, configure, support, and troubleshoot your TCP/IP-based network.

Novell Identity Manager

Java CPD (I) Frans Coenen Department of Computer Science

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Product Standard General Interworking: Internet Server

An Overview of Java. overview-1

Chakchai So-In, Ph.D.

1 Data information is sent onto the network cable using which of the following? A Communication protocol B Data packet

When the transport layer tries to establish a connection with the server, it is blocked by the firewall. When this happens, the RMI transport layer

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

CS 164 Winter 2009 Term Project Writing an SMTP server and an SMTP client (Receiver-SMTP and Sender-SMTP) Due & Demo Date (Friday, March 13th)

Protocolo HTTP. Web and HTTP. HTTP overview. HTTP overview

Transcription:

Network Programming Java provides easy-to-use classes for network programming. These classes integrate nicely with the rest of the language. Acronyms IP TCP UDP URL HTTP FTP SMTP POP Connections = Internet Protocol = Transport Control Protocol = User Datagram Protocol = Uniform Resource Locator = Hypertext Transfer Protocol = File Transfer Protocol = Simple Mail Transfer Protocol = Post Office Protocol A connection with a computer on the Internet is described by 1. A host or domain name (blue.weeg.uiowa.edu) or An IP address, a 32-bit integer written as four bytes (128.255.56.2), called dotted quad format. 2. A port number, a 16-bit integer (1 port 65535). The Domain Naming Service (DNS) translates host names into IP addresses. DNS consists of a set of servers on the Internet that translate host names. Copyright 2005 by Ken Slonneger Network Programming 1

Ports The ports from 1 to 1023 are reserved for well-known network services, for example, 7 echo 9 discard 13 daytime 21 ftp 25 smtp 37 time 43 whois 79 finger 80 http 110 pop3 Networking in Java Java provides classes for programming network applications at a relatively high level. We consider two groups of classes: 1. IP address class 2. TCP classes InetAddress Class Each object of class InetAddress encapsulates one IP address. InetAddress has no public constructors. Objects are created using class methods, called factory methods. InetAddress InetAddress.getByName(String hostname) throws UnknownHostException Also InetAddress [] InetAddress.getAllByName(String hostname) InetAddress InetAddress.getLocalHost() 2 Network Programming Copyright 2005 by Ken Slonneger

Example (in a try block) InetAddress cs = InetAddress.getByName("john.cs.uiowa.edu"); Accessors Instance methods: cs.gethostname() cs.getaddress() returns a String returns a byte array Example: Find IP Addresses List the IP addresses for cnn.com or some other host. Recall that the bytes between 128 and 255 are negative integers as twos complement numbers. import java.net.*; public class Inet public static void main(string [] args) throws UnknownHostException InetAddress [] ia; if (args.length == 1) ia = InetAddress.getAllByName(args[0]); else ia = InetAddress.getAllByName("cnn.com"); for (int k = 0; k < ia.length; k++) System.out.println(ia[k]); System.out.println(ia[k].getHostName()); byte [] bytes = ia[k].getaddress(); Copyright 2005 by Ken Slonneger Network Programming 3

for (int n=0; n<bytes.length; n++) int b = bytes[n]; if (b<0) b = b+256; if (n>0) System.out.print(. ); System.out.print(b); System.out.println(); Negative bytes need to be massaged to put them into the range 0 to 255. Example: Start with the byte -52 byte 1100 1100 int 1111 1111 1111 1111 1111 1111 1100 1100 +256 0000 0000 0000 0000 0000 0001 0000 0000 0000 0000 0000 0000 0000 0000 1100 1100 which is the unsigned byte 204 as an int. Note that the sign is extended when a byte is changed into an int. Output cnn.com/207.25.71.25 cnn.com 207.25.71.25 cnn.com/207.25.71.29 cnn.com 207.25.71.29 cnn.com/64.236.16.20 cnn.com 64.236.16.20 cnn.com/64.236.16.52 cnn.com 64.236.16.52 cnn.com/64.236.16.84 cnn.com 64.236.16.84 cnn.com/64.236.16.116 cnn.com 64.236.16.116 cnn.com/207.25.71.5 cnn.com 207.25.71.5 cnn.com/207.25.71.20 cnn.com 207.25.71.20 4 Network Programming Copyright 2005 by Ken Slonneger

TCP/IP: Connection-Oriented Protocol Similar to a telephone conversation. Server Listens at a particular port for incoming conversations. Client Initiates a conversation with a server by naming the server and the port at which the server is listening. Client Application Socket Server Socket Client Application Socket Server Socket Socket Copyright 2005 by Ken Slonneger Network Programming 5

Sockets A socket is an abstraction that treats a network connection as a stream of bytes that can be read or written. A socket is constructed by a client explicitly when it connects with a server. Socket Class Constructors Socket sock = new Socket("rome.divms.uiowa.edu", 7); If we already have an InetAddress, say inad, use Socket sk = new Socket(inad, 7); Accessors sock.getinetaddress() sock.getport() sock.getlocalport() returns remote host returns remote port returns local port Creating Streams InputStream is = sock.getinputstream(); OutputStream os = sock.getoutputstream(); Closing a Socket sock.close(); 6 Network Programming Copyright 2005 by Ken Slonneger

Example: Echo Client Connect to the echo port on a unix machine. import java.net.*; import java.io.*; public class EchoClient public static void main(string [] args) String hostname; if (args.length > 0) hostname = args[0]; else hostname = "localhost"; try Socket sock = new Socket(hostname, 7); System.out.println("Connected to " + sock.getinetaddress()); BufferedReader instream = new BufferedReader( new InputStreamReader(sock.getInputStream())); boolean autoflush = true; PrintWriter outstream = new PrintWriter( new OutputStreamWriter( sock.getoutputstream()), autoflush); BufferedReader userinput = new BufferedReader( new InputStreamReader(System.in)); Copyright 2005 by Ken Slonneger Network Programming 7

System.out.println("Enter text with. at end"); String aline = userinput.readline(); while (!aline.equals(".")) System.out.println("User: " + aline); outstream.println(aline); System.out.println("Echo: " + instream.readline()); aline = userinput.readline(); sock.close(); catch (UnknownHostException e) System.out.println(e); catch (IOException e) System.out.println(e); % java EchoClient cse.buffalo.edu Connected to cse.buffalo.edu/128.205.32.2 Enter text with. to end Hello buffalo. User: Hello buffalo. Echo: Hello buffalo. How is Lake Erie? User: How is Lake Erie? Echo: How is Lake Erie? This will be the last line. User: This will be the last line. Echo: This will be the last line.. 8 Network Programming Copyright 2005 by Ken Slonneger

Example: Look for Ports Connect to a host and try all the ports from 1 to 1023 to see if they accept a connection. Use a command-line argument. Try on friendly machines only. import java.net.*; import java.io.*; public class Look4Ports public static void main(string [] args) String host; Socket thesocket = null; if (args.length>0) host = args[0]; else host = "localhost"; try for (int k=1; k<1024; k++) try thesocket = new Socket(host, k); System.out.println("Port " + k + " of " + host + " has a server."); catch (ConnectException e) /* no server on this port: throws a ConnectException */ Copyright 2005 by Ken Slonneger Network Programming 9

if (thesocket!=null) thesocket.close(); catch (UnknownHostException e) System.out.println(e); catch (IOException e) System.out.println(e); % java Look4Ports red.weeg.uiowa.edu Port 21 of red.weeg.uiowa.edu has a server. Port 22 of red.weeg.uiowa.edu has a server. Port 23 of red.weeg.uiowa.edu has a server. Port 25 of red.weeg.uiowa.edu has a server. Port 106 of red.weeg.uiowa.edu has a server. Port 110 of red.weeg.uiowa.edu has a server. Port 111 of red.weeg.uiowa.edu has a server. Port 113 of red.weeg.uiowa.edu has a server. Port 512 of red.weeg.uiowa.edu has a server. Port 513 of red.weeg.uiowa.edu has a server. Port 514 of red.weeg.uiowa.edu has a server. Port 620 of red.weeg.uiowa.edu has a server. Port 621 of red.weeg.uiowa.edu has a server. Port 999 of red.weeg.uiowa.edu has a server. 10 Network Programming Copyright 2005 by Ken Slonneger

Server Sockets Constructor ServerSocket ss = new ServerSocket(2233); Parameter is an int specifying the port. The port number must be greater than 1023. Instance Method Socket sock = ss.accept(); Blocks until a client requests session with this host on server port. Returns a Socket when a connection is made. Example: Echo Server Create a server that echoes each string that is sent to it, terminating when BYE is the string. import java.io.*; import java.net.*; public class EchoServer public static void main(string [] args) try ServerSocket ss = new ServerSocket(7007); System.out.println("Echo Server running on " + InetAddress.getLocalHost().getHostName()); Copyright 2005 by Ken Slonneger Network Programming 11

Socket incoming = ss.accept( ); String client = incoming.getinetaddress().gethostname(); System.out.println("Connection made with " + client); BufferedReader br = new BufferedReader( new InputStreamReader(incoming.getInputStream())); PrintWriter pw = new PrintWriter( new OutputStreamWriter( incoming.getoutputstream()), true); pw.println("hello! Enter BYE to exit.\n"); String str = br.readline(); while (str!= null &&!str.trim().equals("bye")) pw.println("echo: " + str + "\n"); str = br.readline(); incoming.close(); catch (IOException e) System.out.println(e); 12 Network Programming Copyright 2005 by Ken Slonneger

The EchoServer can be tested using telnet. A telnet session is initiated by a unix command: % telnet remotemachinename portnumber First Start EchoServer on a machine (l-lnx205). % java EchoServer Echo Server running on l-lnx205.divms.uiowa.edu Connection made with r-lnx233.cs.uiowa.edu Second: Start telnet on r-lnx233.cs.uiowa.edu % telnet l-lnx205.divms.uiowa.edu 7007 Trying... Connected to l-lnx205.divms.uiowa.edu. Escape character is '^]'. Hello! Enter BYE to exit. Hello l-lnx205. Echo: Hello l-lnx205. This session comes from telnet. Echo: This session comes from telnet. BYE Connection closed by foreign host. These lines produced by telnet. Copyright 2005 by Ken Slonneger Network Programming 13

Anonymous Mail Using the simple mail transfer protocol, SMTP, we can send mail anonymously. First, make a connection at port 25 with the server that contains the addressee to whom you want to send the mail and then send the following linefeed-terminated strings: Client Messages <connect> HELO sun.com MAIL FROM: nobody@sun.com RCPT TO: slonnegr DATA Hello from nobody.. Responses from Server 220 smtp.divms.uiowa.edu ESMTP Tue, 9 Nov 2004 12:49:34-0600 (CST) 250 serv01.divms.uiowa.edu Hello [128.255.132.56], pleased to meet you 250 nobody@sun.com... Sender ok 250 slonnegr...recipient ok 354 Enter mail, end with "." on a line by itself 250 PAA24437 Message accepted for delivery 14 Network Programming Copyright 2005 by Ken Slonneger

POP3 Protocol % telnet mail.divms.uiowa.edu 110 Trying... Connected to mail.divms.uiowa.edu. Escape character is '^]'. +OK POP3 mail.divms.uiowa.edu v2001.78 server ready USER slonnegr +OK User name accepted, password please PASS ********* +OK Mailbox open, 249 messages RETR 20 +OK 2659 octets : From: "stephenmosberg" <stephenmosberg@msn.com> To: "Ken Slonneger" <slonnegr@cs.uiowa.edu> Subject: Thank You Date: Mon, 6 May 2002 09:44:45-0400 : Dear Professor Slonneger: I wanted to thank you for your helpful review of the proposal. :. QUIT +OK Sayonara Connection closed by foreign host. Copyright 2005 by Ken Slonneger Network Programming 15

Protocols and Serialization For programs on two different machines to communicate, each needs to know what the other is expecting. For example, email is possible because of the Simple Mail Transfer Protocol (smtp). Suppose we want to provide a new service that clients can use, namely the generation of Domino objects. First we need to define the protocol, call it the Domino Transfer Protocol (dtp). DominoClient DominoServer connect > < Enter number of dominoes desired an int n > < n randomly generated dominoes < terminate connection > Since Domino objects need to be serialized to be sent across the network, all data will be sent through object streams. When object streams are created between two programs, header information including magic numbers are exchanged and verified. Therefore, the object streams must be created in compatible orders. 16 Network Programming Copyright 2005 by Ken Slonneger

Server ObjectOutputStream sock.getoutputstream() ObjectInputStream sock.getinputstream() Client ObjectInputStream sock.getinputstream() ObjectOutputStream sock.getoutputstream() Domino Server import java.io.*; import java.net.*; public class DominoServer public static void main(string[] args) try ServerSocket ss = new ServerSocket(9876); System.out.println("Domino Server running."); System.out.println("Use cntl-c to stop server."); while (true) Socket sock = ss.accept( ); String client = sock.getinetaddress().gethostname(); System.out.println("Connected to client " + client); Copyright 2005 by Ken Slonneger Network Programming 17

InputStream in = sock.getinputstream(); OutputStream out = sock.getoutputstream(); // Note order of Object stream creation. ObjectOutputStream outstrm = new ObjectOutputStream(out); ObjectInputStream instrm = new ObjectInputStream(in); outstrm.writeutf("enter number of dominoes desired"); outstrm.flush(); int count = instrm.readint(); for (int k=1; k<=count; k++) Domino d = new Domino(true); outstrm.writeobject(d); System.out.println(count + " dominoes sent to " + client); sock.close(); // flushes the stream // while (true) catch (IOException e) System.out.println(e); /****************************************************/ class Domino implements Serializable : 18 Network Programming Copyright 2005 by Ken Slonneger

Domino Client import java.net.*; import java.io.*; public class DominoClient public static void main(string[] args) String hostname; int port = 9876; if (args.length == 1) hostname = args[0]; else System.out.println( "Usage: java DominoClient servername"); return; try Socket sock = new Socket(hostname, port); String server = sock.getinetaddress().gethostname(); System.out.println("Connected to server " + server); InputStream in = sock.getinputstream(); OutputStream out = sock.getoutputstream(); // Note order of Object stream creation. ObjectInputStream instrm = new ObjectInputStream(in); ObjectOutputStream outstrm = new ObjectOutputStream(out); Scanner scan = new Scanner(System.in); Copyright 2005 by Ken Slonneger Network Programming 19

String start = instrm.readutf(); System.out.print(start + ": "); String aline = userinput.readline(); int num; try num = scan.nextint(); catch (InputMismatchException e) num = 0; outstrm.writeint(num); outstrm.flush(); for (int k=1; k<=num; k++) Domino d = (Domino)inStrm.readObject(); System.out.println("Domino " + k +": " + d); sock.close(); catch (UnknownHostException e) System.out.println(e); catch (ClassNotFoundException e) System.out.println(e); catch (IOException e) System.out.println(e); /****************************************************/ class Domino implements Serializable : 20 Network Programming Copyright 2005 by Ken Slonneger

Sample Server Output % java DominoServer Domino Server running on l-lnx205.divms.uiowa.edu Use control-c to terminate server. Connection from client: r-lnx233.cs.uiowa.edu 5 dominoes sent to r-lnx233.cs.uiowa.edu Sample Client Output % java DominoClient l-lnx205.divms.uiowa.edu Connected to server l-lnx205.divms.uiowa.edu Enter the number of dominoes desired: 5 Domino 1: <1, 1> UP Domino 2: <2, 3> UP Domino 3: <0, 0> UP Domino 4: <1, 4> UP Domino 5: <1, 1> UP Another Protocol Most network protocols are text-based. The client and server exchange text messages (strings). Examples: echo, date, smtp, pop3, http A Non-text Protocol: time Some machines have a server running on port 37 that returns binary data. When a client connects to such a server at port 37, the server returns a four-byte (32-bit) unsigned integer representing the number of seconds since midnight on January 1, 1900 GMT. Copyright 2005 by Ken Slonneger Network Programming 21

Since the number of seconds that have elapsed since January 1, 1900 GMT is already larger than the biggest positive int in Java (2,147,483,647), we must convert the four byte number to long to see the correct value. Client Program import java.net.*; import java.io.*; // TCP to port 37 public class Time37 public static void main(string [] args) throws IOException String host; if (args.length == 1) host = args[0]; else throw new RuntimeException( "Usage: java Time37 time.nist.gov"); Socket s = new Socket(host, 37); InputStream instream = s.getinputstream(); byte [] buffer = new byte [4]; int count = instream.read(buffer); long secs = 0; for (int k=0; k<4; k++) // use long arithmetic so that long b = buffer[k]; // after the shift left one byte, secs = secs << 8; // the number will be positive secs = secs (b & 0xff); // place byte in right-most // position 22 Network Programming Copyright 2005 by Ken Slonneger

System.out.println(secs + " seconds since January 1, 1900, GMT"); Sample Execution % java Time37 time.nist.gov 3309015511 seconds since January 1, 1900, GMT Exercise: Calculate the number of day, hours, minutes, and seconds that have elapsed since January 1, 1900 GMT. Exercise: Use a DataInputStream to read the four bytes as an int. If the number is negative (it will be), use long arithmetic to make if positive by adding 2 32. HTTP The hypertext transport protocol defines the convention that allows a browser to find web pages on a server. The basic web page fetch follows a simple protocol. Protocol 1. Connect to the machine where the server in running, normally at port 80. 2a. Send a line of text that includes the name of the file to be returned. GET /index.html HTTP/1.0 In most web directories, the file index.html contains the starting web page for the directory. 2b. Or omit the file name. GET / HTTP/1.0 Copyright 2005 by Ken Slonneger Network Programming 23

3. Send a header specifying the host (for HTTP 1.1): Host: server we are connecting to 4. Enter one entirely blank line. At this point the web server should send back the web page as a stream of text, usually written in HTML. The program below acts as a client that connects to a web server given by its first command-line argument, and downloads a file given by its second command-line argument. If no command-line arguments are supplied, the program connects to yahoo.com and downloads index.html. The program uses a Scanner object to read the lines of text sent back by the web server. HttpClient.java import java.io.*; import java.net.*; import java.util.scanner; public class HttpClient public static void main(string [] args) throws IOException String server="yahoo.com", file="index.html"; if (args.length == 2) file = args[1]; if (args.length >= 1) server = args[0]; Socket sock = new Socket(server, 80); PrintWriter pw = new PrintWriter(sock.getOutputStream(),true); 24 Network Programming Copyright 2005 by Ken Slonneger

pw.println("get /" + file + " HTTP/1.0"); pw.println("host: " + server); // Required by HTTP 1.1 pw.println(); Scanner scan = new Scanner(sock.getInputStream()); while (scan.hasnextline()) String str = scan.nextline(); System.out.println(str); sock.close(); Execution % java HttpClient <!-- info_setup:ads,ad-location:z,ad-spaceid:19849501 225 --> <!-- info_insertion:z 225 --> <!-- spaceid:19849501 9764 --> <html> <head><title>ask Yahoo!</title> <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" l gen true for "http://ask.yahoo.com" r ( nz 0 vz 0 lz 0 oz 0 ca 1))'> </head> <body bgcolor=white> <center> <table border=0 width=600 cellspacing=0 cellpadding=0> <tr> <td width=1%><img src=http://us.i1.yimg.com/us.yimg.com/i/us/ask/gr/ask1.gif alt="ask Yahoo!" border=0 width=167 height=35></td> <td> <table border=0 cellspacing=0 cellpadding=0 width=100%> <tr> <td align=right valign=bottom><font face=arial size=-1> Copyright 2005 by Ken Slonneger Network Programming 25

<a href="http://rd.yahoo.com/ask/?http://dir.yahoo.com">web Site Directory</a> - : Using Telnet % telnet java.sun.com 80 Trying 209.249.116.141... Connected to 209.249.116.141.available (209.249.116.141). Escape character is '^]'. GET / HTTP/1.0 HTTP/1.1 200 OK Server: Sun-ONE-Web-Server/6.1 Date: Thu, 12 May 2005 19:39:11 GMT Content-type: text/html;charset=iso-8859-1 Set-Cookie: SUN_ID=128.255.44.205:255751115926751; EXPIRES=Wednesday, 31-Dec-2025 23:59:59 GMT; DOMAIN=.sun.com; PATH=/ Set-cookie: JSESSIONID=514ED4E39D287F2DA0479869E05C1359;Path=/ Connection: close <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>java Technology</title> <meta name="keywords" content="java, platform" /> <meta name="description" content="java technology is a portfolio of products that are based on the power of networks and the idea that the same software should run on many different kinds of systems and devices." /> : 26 Network Programming Copyright 2005 by Ken Slonneger