This document provides a tutorial on network programming in Java. It introduces Java network programming and the HTTP protocol. It discusses how Java uses sockets to establish connections between clients and servers. It also describes the Java URL class, which makes it easier to work with HTTP connections by abstracting away the low-level socket implementation. The tutorial provides examples of both an HTTP client and server implemented in Java using sockets and the URL class.
The document describes 8 programs related to networking in Java. Program 1 obtains the IP address of a website. Program 2 connects to the home page of yahoo.com and displays the HTML. Program 3 parses a URL into its components. Program 4 translates between IP addresses and host names. Program 5 prints all IP addresses of a domain. Program 6 obtains the local machine's IP address. Program 7 finds the host name given an IP address. Program 8 downloads a file from the web and saves or displays it. The last part describes a client-server program with a server that echoes back a string sent by the client.
The document discusses socket programming and provides an overview of client-server applications using sockets. It describes how sockets allow for interprocess communication using the client-server model. The key steps for creating TCP and UDP client and server applications in both C and Java programming languages are outlined, including how to create sockets, bind sockets, connect sockets, send and receive data. Code examples of a TCP client and server application written in C are also provided.
The document discusses network programming with sockets. It outlines basic socket programming concepts like client-server models, TCP and UDP services, and BSD sockets. It then describes key socket functions for creation and setup, establishing connections, sending/receiving data, and tearing down connections.
Java Network Programming getting started, Getting Started with java network programming, two tier architecture, java client server programming, core java, java to standard edition, core java, Introduction to network programming in java
This document discusses socket programming concepts in Java including server-client communication using sockets, the InetAddress class and its methods like getLocalHost(), getByName(), and getAllByName(), and the Socket and ServerSocket classes. It provides code examples to demonstrate how to use these classes and methods to establish connections between a client and server and exchange data over the network.
Socket programming allows applications on networked computers to communicate reliably using TCP or unreliably using UDP. A socket represents an open connection between two endpoints and has methods to get input/output streams, the remote host/port, and local port. A client socket connects to a server, while a server socket listens on a port and accepts connections from clients.
This document provides an overview of client-server networking concepts in Java. It discusses elements like network basics, ports and sockets. It explains how to implement both TCP and UDP clients and servers in Java using socket classes. Sample code is provided for an echo client-server application using TCP and a quote client-server application using UDP. Exception handling for sockets is also demonstrated.
The document describes 8 programs related to networking in Java. Program 1 obtains the IP address of a website. Program 2 connects to the home page of yahoo.com and displays the HTML. Program 3 parses a URL into its components. Program 4 translates between IP addresses and host names. Program 5 prints all IP addresses of a domain. Program 6 obtains the local machine's IP address. Program 7 finds the host name given an IP address. Program 8 downloads a file from the web and saves or displays it. The last part describes a client-server program with a server that echoes back a string sent by the client.
The document discusses socket programming and provides an overview of client-server applications using sockets. It describes how sockets allow for interprocess communication using the client-server model. The key steps for creating TCP and UDP client and server applications in both C and Java programming languages are outlined, including how to create sockets, bind sockets, connect sockets, send and receive data. Code examples of a TCP client and server application written in C are also provided.
The document discusses network programming with sockets. It outlines basic socket programming concepts like client-server models, TCP and UDP services, and BSD sockets. It then describes key socket functions for creation and setup, establishing connections, sending/receiving data, and tearing down connections.
Java Network Programming getting started, Getting Started with java network programming, two tier architecture, java client server programming, core java, java to standard edition, core java, Introduction to network programming in java
This document discusses socket programming concepts in Java including server-client communication using sockets, the InetAddress class and its methods like getLocalHost(), getByName(), and getAllByName(), and the Socket and ServerSocket classes. It provides code examples to demonstrate how to use these classes and methods to establish connections between a client and server and exchange data over the network.
Socket programming allows applications on networked computers to communicate reliably using TCP or unreliably using UDP. A socket represents an open connection between two endpoints and has methods to get input/output streams, the remote host/port, and local port. A client socket connects to a server, while a server socket listens on a port and accepts connections from clients.
This document provides an overview of client-server networking concepts in Java. It discusses elements like network basics, ports and sockets. It explains how to implement both TCP and UDP clients and servers in Java using socket classes. Sample code is provided for an echo client-server application using TCP and a quote client-server application using UDP. Exception handling for sockets is also demonstrated.
Overview of socket API.
A network socket is an interface for an application to connect to a host‘s network stack (part of the OS). Sockets provide an abstraction of the network. Applications use the transport services available on the socket interface for communication with a peer application.
Transport protocol such as TCP, UDP or SCTP offer different levels of service. TCP for example provides reliable stream-oriented transport service while UDP more reflects the best-effort kind of service provided by the underlying IP protocol layer.
Sockets are bound to a transport address. For TCP/IP sockets this means an IP address and port number.
Sockets provide only very basic data transport services without any higher level functions like parameter marshaling or serialization. These functions have to be performed by the applications. These functions are often hidden in middleware platforms like distributed object technologies (CORBA, RMI, DCOM) or web service frameworks (WCF, JAX-WS).
Multicast sockets make the IP multicast capability accessible to applications. Multicast sockets are often used for streaming services where multiple applications are recipients of the same data packets.
Socket programming uses a client-server model where the client initiates contact with the server to request a service. It uses sockets to allow two processes to communicate by sending and receiving data through the socket. The socket API provides functions to create, bind, listen for, accept, and communicate over sockets. It defines sockets as endpoints for communication between processes running on the same or different devices on a network.
Application Layer and Socket Programmingelliando dias
The document discusses computer networking concepts related to the application layer and socket programming. It provides an overview of client-server applications and protocols, and describes how sockets allow applications to communicate over TCP and UDP. Specifically, it explains how servers can use sockets, binding, listening and accepting to establish TCP connections with clients. It also explains how clients can use sockets and connecting to communicate with servers. For UDP, it describes how servers can use sockets and binding to receive datagrams, while clients can use sockets and sending to communicate with servers.
The document discusses socket programming and provides code examples for establishing sockets on both the client and server side. It explains that a socket is a communication mechanism that allows clients and servers to communicate locally or across networks. It then provides the key steps for setting up both connection-oriented and connectionless sockets, including creating and binding sockets, listening for connections, accepting connections, reading/writing data. It also discusses enhancements like allowing a server to handle multiple clients by forking new processes.
This document discusses network programming clients. It begins by defining clients and servers, explaining that clients initiate connections by specifying a host and port, while servers listen on a port without specifying a host. It then provides the basic steps for implementing a generic network client in Java: creating a socket, input and output streams, performing I/O, and closing the socket. Additional topics covered include parsing strings with StringTokenizer, an example client that verifies email addresses, and a MailAddress class to parse email addresses.
The document discusses sockets and the client-server model for interprocess communication. It describes what sockets are, the different types of sockets (STREAM, DATAGRAM, RAW), and how they are used for reliable and unreliable communication between processes. It provides code examples for creating, connecting, sending, receiving and closing sockets in both client and server applications using TCP and UDP. Key system calls for sockets like socket(), bind(), listen(), accept(), connect(), send(), recv(), close() are also explained.
Sockets allow for two-way communication between hosts in a network. There are two types of sockets: server sockets and client sockets. Server sockets wait for connection requests from clients, while client sockets are used to send and receive data from servers. Sockets provide input and output streams for transmission of data between endpoints.
This document contains information about TCP/IP sockets and network programming in C, including:
1) It defines the sockaddr_in structure for IPv4 socket addressing with fields for the address family, port number, and 32-bit IPv4 address.
2) It describes the basic socket calls like socket(), bind(), listen(), accept(), connect(), read(), write(), and close() used for network programming.
3) It provides code examples for a simple TCP echo client and server to illustrate how these socket calls are used for communication between networked applications.
Introduction
This Tutorial is On Socket Programming In C Language for Linux. Instructions Give Below will only work On Linux System not in windows.
Socket API In windows is called Winsock and there we can discuss about that in another tutorial.
What is Socket?
Sockets are a method for communication between a client program and a server program in a network.
A socket is defined as "the endpoint in a connection." Sockets are created and used with a set of programming requests or "function calls" sometimes called the sockets application programming interface (API).
The most common sockets API is the Berkeley UNIX C interface for sockets.
Sockets can also be used for communication between processes within the same computer.
Socket programming allows processes to communicate over a network. Key aspects include:
- Demultiplexing packets into processes using port numbers
- Converting between host and network byte order
- Sockets representing an endpoint for communication and identified by address/port pairs
- Functions for binding addresses, listening for connections, accepting connections, and sending/receiving data over established sockets.
Socket programming allows applications to communicate over a network. Sockets provide an interface between applications and the network. There are two main types of sockets: SOCK_STREAM for reliable, ordered connections and SOCK_DGRAM for unreliable datagrams. A socket is created with the socket() call and configured with bind() and connect()/listen()+accept() for servers and clients respectively. Data is sent and received with send()/recv() or sendto()/recvfrom().
TCP sockets allow for communication between applications over the internet. A server creates a ServerSocket to listen for incoming connections on a specific port. When a client connects, the server accepts the connection to get a Socket. Both client and server then obtain input and output streams from the Socket to send and receive data. The connection is closed once communication is complete. Multithreading allows servers to handle multiple clients concurrently by spawning a new thread for each connection.
An overview of the HTTP protocol showing the protocol basics such as protocol versions, messages, headers, status codes, connection management, cookies and more.
But it still remains an overview without in-depth information. Also some key aspects are left out (because of limited time) such as authentication, content negotiation, robots, web architecture etc..
The overview on Socket Programming that will lead you how to program with a short example of programming which is in slide. With the help of this you can understand about network programming.
This document discusses socket programming in C/C++. It describes sockets as a protocol-independent method of connecting processes. Sockets can be connection-based or connectionless, reliable or unreliable. Key socket APIs like socket(), bind(), listen(), accept(), connect(), and related functions are explained. Connection-based communication with a TCP client and server is outlined, with the server performing actions like binding, listening, and accepting connections, and the client performing connection.
The Hypertext Transfer Protocol (HTTP) is an application layer protocol for distributed, collaborative, hypermedia information systems and is the foundation for data communication on the World Wide Web. HTTP defines methods like GET and POST to indicate the desired action on a resource and uses status codes in responses. It also uses headers in requests and responses to define parameters of the transaction. HTTP typically uses TCP port 80 to allow a client to open a connection and send requests to a server, which responds with messages that may contain requested resources or error information.
This document provides an overview and roadmap for a course on programming TCP/IP with sockets. The course covers important concepts on day one and then focuses each subsequent day on specific socket routines, library routines, sample client/server code, and VMS specifics. Slides and source code for the course are available via anonymous FTP from the listed hosts and directories.
The document contains code for simulating various network protocols like sliding window protocol, stop and wait protocol, socket programming for client server communication, ARP, RARP and code to simulate PING and TRACEROUTE commands. It includes algorithms, programs written in Java with sample inputs and outputs. The programs demonstrate implementation of network layer protocols and utilities.
This document discusses socket programming in .NET, including how it can be used to create a chat application. Socket programming allows communication between applications through TCP/IP and uses the System.Net.Sockets namespace. A chat application would require a server that can connect to multiple clients simultaneously and asynchronously send and receive data from each client. The clients must also be able to asynchronously send and receive data from the server to allow for real-time chatting between multiple connected users. Security considerations are also important for such a networked application.
This PowerPoint discusses adjectives and adverbs, including their definitions and rules. Adjectives modify nouns and pronouns by describing qualities like kind, which one, or how many. Adverbs modify verbs, adjectives, or other adverbs by describing manner, place, time, degree, or frequency. Examples are provided to illustrate simple adverbs of manner, place, and time, as well as interrogative, negative, and familiar adverbs.
The document discusses signs and symptoms of drug and alcohol use in teenagers and strategies for prevention. It provides statistics on national drug and alcohol use among students and risk factors. It recommends that parents establish rules, communicate with their children, and model healthy behaviors to help teenagers make good choices and reduce risky behavior.
The document summarizes several ancient Mesoamerican civilizations. It describes four major structures in Teotihuacan including the Pyramids of the Sun and Moon. It notes the Olmecs were the first major tribe and explains their name means "rubber people." It provides details on the Mayan writing system of glyphs and their religious practices including human sacrifices and worship of the dead. It notes the Aztecs founded Tenochtitlan and belonged to clans called calpolli that functioned as democracies where women could not vote.
Overview of socket API.
A network socket is an interface for an application to connect to a host‘s network stack (part of the OS). Sockets provide an abstraction of the network. Applications use the transport services available on the socket interface for communication with a peer application.
Transport protocol such as TCP, UDP or SCTP offer different levels of service. TCP for example provides reliable stream-oriented transport service while UDP more reflects the best-effort kind of service provided by the underlying IP protocol layer.
Sockets are bound to a transport address. For TCP/IP sockets this means an IP address and port number.
Sockets provide only very basic data transport services without any higher level functions like parameter marshaling or serialization. These functions have to be performed by the applications. These functions are often hidden in middleware platforms like distributed object technologies (CORBA, RMI, DCOM) or web service frameworks (WCF, JAX-WS).
Multicast sockets make the IP multicast capability accessible to applications. Multicast sockets are often used for streaming services where multiple applications are recipients of the same data packets.
Socket programming uses a client-server model where the client initiates contact with the server to request a service. It uses sockets to allow two processes to communicate by sending and receiving data through the socket. The socket API provides functions to create, bind, listen for, accept, and communicate over sockets. It defines sockets as endpoints for communication between processes running on the same or different devices on a network.
Application Layer and Socket Programmingelliando dias
The document discusses computer networking concepts related to the application layer and socket programming. It provides an overview of client-server applications and protocols, and describes how sockets allow applications to communicate over TCP and UDP. Specifically, it explains how servers can use sockets, binding, listening and accepting to establish TCP connections with clients. It also explains how clients can use sockets and connecting to communicate with servers. For UDP, it describes how servers can use sockets and binding to receive datagrams, while clients can use sockets and sending to communicate with servers.
The document discusses socket programming and provides code examples for establishing sockets on both the client and server side. It explains that a socket is a communication mechanism that allows clients and servers to communicate locally or across networks. It then provides the key steps for setting up both connection-oriented and connectionless sockets, including creating and binding sockets, listening for connections, accepting connections, reading/writing data. It also discusses enhancements like allowing a server to handle multiple clients by forking new processes.
This document discusses network programming clients. It begins by defining clients and servers, explaining that clients initiate connections by specifying a host and port, while servers listen on a port without specifying a host. It then provides the basic steps for implementing a generic network client in Java: creating a socket, input and output streams, performing I/O, and closing the socket. Additional topics covered include parsing strings with StringTokenizer, an example client that verifies email addresses, and a MailAddress class to parse email addresses.
The document discusses sockets and the client-server model for interprocess communication. It describes what sockets are, the different types of sockets (STREAM, DATAGRAM, RAW), and how they are used for reliable and unreliable communication between processes. It provides code examples for creating, connecting, sending, receiving and closing sockets in both client and server applications using TCP and UDP. Key system calls for sockets like socket(), bind(), listen(), accept(), connect(), send(), recv(), close() are also explained.
Sockets allow for two-way communication between hosts in a network. There are two types of sockets: server sockets and client sockets. Server sockets wait for connection requests from clients, while client sockets are used to send and receive data from servers. Sockets provide input and output streams for transmission of data between endpoints.
This document contains information about TCP/IP sockets and network programming in C, including:
1) It defines the sockaddr_in structure for IPv4 socket addressing with fields for the address family, port number, and 32-bit IPv4 address.
2) It describes the basic socket calls like socket(), bind(), listen(), accept(), connect(), read(), write(), and close() used for network programming.
3) It provides code examples for a simple TCP echo client and server to illustrate how these socket calls are used for communication between networked applications.
Introduction
This Tutorial is On Socket Programming In C Language for Linux. Instructions Give Below will only work On Linux System not in windows.
Socket API In windows is called Winsock and there we can discuss about that in another tutorial.
What is Socket?
Sockets are a method for communication between a client program and a server program in a network.
A socket is defined as "the endpoint in a connection." Sockets are created and used with a set of programming requests or "function calls" sometimes called the sockets application programming interface (API).
The most common sockets API is the Berkeley UNIX C interface for sockets.
Sockets can also be used for communication between processes within the same computer.
Socket programming allows processes to communicate over a network. Key aspects include:
- Demultiplexing packets into processes using port numbers
- Converting between host and network byte order
- Sockets representing an endpoint for communication and identified by address/port pairs
- Functions for binding addresses, listening for connections, accepting connections, and sending/receiving data over established sockets.
Socket programming allows applications to communicate over a network. Sockets provide an interface between applications and the network. There are two main types of sockets: SOCK_STREAM for reliable, ordered connections and SOCK_DGRAM for unreliable datagrams. A socket is created with the socket() call and configured with bind() and connect()/listen()+accept() for servers and clients respectively. Data is sent and received with send()/recv() or sendto()/recvfrom().
TCP sockets allow for communication between applications over the internet. A server creates a ServerSocket to listen for incoming connections on a specific port. When a client connects, the server accepts the connection to get a Socket. Both client and server then obtain input and output streams from the Socket to send and receive data. The connection is closed once communication is complete. Multithreading allows servers to handle multiple clients concurrently by spawning a new thread for each connection.
An overview of the HTTP protocol showing the protocol basics such as protocol versions, messages, headers, status codes, connection management, cookies and more.
But it still remains an overview without in-depth information. Also some key aspects are left out (because of limited time) such as authentication, content negotiation, robots, web architecture etc..
The overview on Socket Programming that will lead you how to program with a short example of programming which is in slide. With the help of this you can understand about network programming.
This document discusses socket programming in C/C++. It describes sockets as a protocol-independent method of connecting processes. Sockets can be connection-based or connectionless, reliable or unreliable. Key socket APIs like socket(), bind(), listen(), accept(), connect(), and related functions are explained. Connection-based communication with a TCP client and server is outlined, with the server performing actions like binding, listening, and accepting connections, and the client performing connection.
The Hypertext Transfer Protocol (HTTP) is an application layer protocol for distributed, collaborative, hypermedia information systems and is the foundation for data communication on the World Wide Web. HTTP defines methods like GET and POST to indicate the desired action on a resource and uses status codes in responses. It also uses headers in requests and responses to define parameters of the transaction. HTTP typically uses TCP port 80 to allow a client to open a connection and send requests to a server, which responds with messages that may contain requested resources or error information.
This document provides an overview and roadmap for a course on programming TCP/IP with sockets. The course covers important concepts on day one and then focuses each subsequent day on specific socket routines, library routines, sample client/server code, and VMS specifics. Slides and source code for the course are available via anonymous FTP from the listed hosts and directories.
The document contains code for simulating various network protocols like sliding window protocol, stop and wait protocol, socket programming for client server communication, ARP, RARP and code to simulate PING and TRACEROUTE commands. It includes algorithms, programs written in Java with sample inputs and outputs. The programs demonstrate implementation of network layer protocols and utilities.
This document discusses socket programming in .NET, including how it can be used to create a chat application. Socket programming allows communication between applications through TCP/IP and uses the System.Net.Sockets namespace. A chat application would require a server that can connect to multiple clients simultaneously and asynchronously send and receive data from each client. The clients must also be able to asynchronously send and receive data from the server to allow for real-time chatting between multiple connected users. Security considerations are also important for such a networked application.
This PowerPoint discusses adjectives and adverbs, including their definitions and rules. Adjectives modify nouns and pronouns by describing qualities like kind, which one, or how many. Adverbs modify verbs, adjectives, or other adverbs by describing manner, place, time, degree, or frequency. Examples are provided to illustrate simple adverbs of manner, place, and time, as well as interrogative, negative, and familiar adverbs.
The document discusses signs and symptoms of drug and alcohol use in teenagers and strategies for prevention. It provides statistics on national drug and alcohol use among students and risk factors. It recommends that parents establish rules, communicate with their children, and model healthy behaviors to help teenagers make good choices and reduce risky behavior.
The document summarizes several ancient Mesoamerican civilizations. It describes four major structures in Teotihuacan including the Pyramids of the Sun and Moon. It notes the Olmecs were the first major tribe and explains their name means "rubber people." It provides details on the Mayan writing system of glyphs and their religious practices including human sacrifices and worship of the dead. It notes the Aztecs founded Tenochtitlan and belonged to clans called calpolli that functioned as democracies where women could not vote.
Ancient Greece was a peninsula in the Mediterranean Sea around the size of Louisiana. It had a mountainous geography which caused Greek communities to develop independently and often fight each other. Due to their coastal location, Greeks developed advanced naval technologies for trade and warfare. They also invented necessary structures like aqueducts for transporting fresh water in their mountainous terrain. Greek innovations included sports, architecture using columns and arches, military weapons like catapults, and the foundations of Western democracy in city-states like Athens. Alexander the Great later conquered the Persian Empire and spread Greek culture and ideas widely, influencing structures in both the ancient and modern world.
The document discusses the proper use of adjectives and adverbs. It defines adjectives as words that modify nouns and pronouns, and adverbs as words that modify verbs, adjectives, and other adverbs. It provides examples of adjectives and adverbs, and discusses their comparative and superlative forms. It also covers compound adjectives and advises placing adjectives and adverbs close to the words they modify.
The document provides guidance on writing different types of essays for the Alabama state writing assessment. It defines expository, descriptive, persuasive, and narrative essays and provides examples of prompts for each type. It then offers tips for outlining, drafting, and revising essays, such as determining the prompt type, reading it multiple times, brainstorming ideas, and using transitions to connect paragraphs.
An adjective describes or modifies a noun or pronoun by indicating attributes such as size, color, or number. An adverb describes or modifies verbs, adjectives, or other adverbs by indicating manner, place, time, frequency, or degree. Adjectives provide details about nouns while adverbs provide details about verbs, adjectives, and other adverbs by answering how, when, where, or to what extent. Both adjectives and adverbs add description to make meanings clearer.
Artificial intelligence (AI) is everywhere, promising self-driving cars, medical breakthroughs, and new ways of working. But how do you separate hype from reality? How can your company apply AI to solve real business problems?
Here’s what AI learnings your business should keep in mind for 2017.
This document provides an overview of networking concepts in Java including:
1) It outlines topics on networking basics like IP addresses, ports, protocols and client-server interactions.
2) It describes how to write networking clients and servers using sockets.
3) It provides an example of writing a simple ICQ client-server application to demonstrate sockets.
4) It discusses communicating with web servers by retrieving and sending information using URLs and URLConnections.
The Presentation given at Guru Gobind Singh Polytechnic, Nashik for Third Year Information Technology and Computer Engineering Students on 08/02/2011.
Topic: Java Network Programming
The document discusses network programming and Java sockets. It introduces elements of client-server computing including networking basics like TCP, UDP and ports. It then covers Java sockets, explaining how to implement both a server and client using Java sockets. Code examples are provided of a simple server and client. The conclusion emphasizes that Java makes socket programming easier than other languages like C.
The document provides an overview of object oriented programming and network programming concepts. It discusses topics like IP addresses, ports, sockets, client-server programming, and the java.net and java.util packages. The java.net package contains classes for network programming in Java like Socket, ServerSocket, URL, and InetAddress. The java.util package contains general-purpose utility classes like ArrayList, HashMap, Properties and Date.
The presentation given at MSBTE sponsored content updating program on 'Advanced Java Programming' for Diploma Engineering teachers of Maharashtra. Venue: Guru Gobind Singh Polytechnic, Nashik
Date: 22/12/2010
Session: Java Network Programming
[Type text]ECET465Project 2Project Assignment 2 Building a Mul.docxhanneloremccaffery
[Type text] ECET465
Project 2Project Assignment 2: Building a Multi-Threaded Web Server
This project assignment is due at the end of the seventh week of the course and is worth 7% of your total grade.
In this project, we will develop a Web server in two steps. In the end, you will have built a multi-threaded Web server that is capable of processing multiple simultaneous service requests in parallel. Section 2.7 of your text may offer you some insight and help. You should be able to demonstrate that your Web server is capable of delivering your home page to a Web browser.
We are going to implement Version 1.0 of HTTP, as defined in RFC 1945, where separate HTTP requests are sent for each component of the Web page. The server will be able to handle multiple simultaneous service requests in parallel. This means that the Web server is multi-threaded. In the main thread, the server listens to a fixed port. When it receives a TCP connection request, it sets up a TCP connection through another port and services the request in a separate thread. To simplify this programming task, we will develop the code in two stages. In the first stage, you will write a multi-threaded server that simply displays the contents of the HTTP request message that it receives. After this program is running properly, you will add the code required to generate an appropriate response.
As you are developing the code, you can test your server from a Web browser. Just remember that you are not serving through the standard port 80, so you need to specify the port number within the URL that you give to your browser. For example, if your machine's name is host.someschool.edu, your server is listening to port 6789, and you want to retrieve the file index.html, then you would specify the following URL within the browser: http://host.someschool.edu:6789/index.html
If you omit ":6789," the browser will assume port 80, which most likely will not have a server listening on it.
When the server encounters an error, it sends a response message with the appropriate HTML source so that the error information is displayed in the browser window.
Web Server in Java: Part A
In the following steps, we will go through the code for the first implementation of our Web server. Wherever you see "?," you will need to supply a missing detail.
Our first implementation of the Web server will be multi-threaded, where the processing of each incoming request will take place inside a separate thread of execution. This allows the server to service multiple clients in parallel, or to perform multiple file transfers to a single client in parallel. When we create a new thread of execution, we need to pass to the Thread's constructor an instance of some class that implements the Runnable interface. This is the reason why we define a separate class called HttpRequest. The structure of the Web server is shown below: import java.io.* ;import java.net.* ;import java.util.* ;public final class WebServer{ public.
This document discusses network programming and Java sockets. It begins with an introduction to client-server computing and networking basics like TCP, UDP, and ports. It then covers Java sockets in detail, including how to implement a server that can accept multiple clients by creating a new thread for each, and how to implement a client. Sample code is provided for a simple single-threaded server and client. The document concludes that programming client-server applications in Java using sockets is easier than in other languages like C.
The document discusses different types of sockets in Java network programming:
- TCP/IP client socket and TCP/IP server socket are used for reliable, bidirectional stream-based connections between hosts using TCP/IP. The client socket connects to the server socket.
- A Java DatagramSocket class represents a connectionless socket for sending and receiving datagram packets without reliability or sequencing. Commonly used DatagramSocket constructors are described.
- An example program is provided to demonstrate passing a message from a server to a client using sockets, showing the client and server code.
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 4...WebStackAcademy
Setting up a servlet environment
Servlets are Java programs that run on a Web server and build Web pages. Here are a few definitions:
Servlet Development Kits
Java Servlet Development Kit (JSDK) provides Servlet API classes (servlet.jar). Place servlet.jar into CLASSPATH, so that java classes can access it.
Servlet Engines
A servlet is a Java class that needs to be executed in a Java VM by servlet engine. The servlet engine loads the servlet class the first time the servlet is requested. The servlet then stays loaded to handle multiple requests until it is explicitly unloaded or the servlet engine is shut down.
Following are few WebServers that supports servlets:
Apache Tomcat
BEA WebLogic
IBM Websphere
Sun's Java Web Server (JWS)
Apache Tomcat.
Java Servlet Development Kit (JSDK)
692015 programming assignment 1 building a multithreaded wsmile790243
The document describes the steps to build a multi-threaded web server in Java that can process multiple HTTP requests simultaneously in separate threads. It provides code snippets to create a basic server that displays request headers, and then extends it to analyze requests and send appropriate response messages containing status lines and file contents or error messages.
Project Assignment 2 Building a Multi-Threaded Web ServerThis pro.docxkacie8xcheco
Project Assignment 2: Building a Multi-Threaded Web Server
This project assignment is due at the end of the seventh week of the course and is worth 7% of your total grade.
In this project, we will develop a Web server in two steps. In the end, you will have built a multi-threaded Web server that is capable of processing multiple simultaneous service requests in parallel. Section 2.7 of your text may offer you some insight and help. You should be able to demonstrate that your Web server is capable of delivering your home page to a Web browser.
We are going to implement Version 1.0 of HTTP, as defined in
RFC 1945
, where separate HTTP requests are sent for each component of the Web page. The server will be able to handle multiple simultaneous service requests in parallel. This means that the Web server is multi-threaded. In the main thread, the server listens to a fixed port. When it receives a TCP connection request, it sets up a TCP connection through another port and services the request in a separate thread. To simplify this programming task, we will develop the code in two stages. In the first stage, you will write a multi-threaded server that simply displays the contents of the HTTP request message that it receives. After this program is running properly, you will add the code required to generate an appropriate response.
As you are developing the code, you can test your server from a Web browser. Just remember that you are not serving through the standard port 80, so you need to specify the port number within the URL that you give to your browser. For example, if your machine's name is
host.someschool.edu
, your server is listening to port 6789, and you want to retrieve the file
index.html
, then you would specify the following URL within the browser:
http://host.someschool.edu:6789/index.html
If you omit ":6789," the browser will assume port 80, which most likely will not have a server listening on it.
When the server encounters an error, it sends a response message with the appropriate HTML source so that the error information is displayed in the browser window.
Web Server in Java: Part A
In the following steps, we will go through the code for the first implementation of our Web server. Wherever you see "?," you will need to supply a missing detail.
Our first implementation of the Web server will be multi-threaded, where the processing of each incoming request will take place inside a separate thread of execution. This allows the server to service multiple clients in parallel, or to perform multiple file transfers to a single client in parallel. When we create a new thread of execution, we need to pass to the Thread's constructor an instance of some class that implements the
Runnable
interface. This is the reason why we define a separate class called
HttpRequest
. The structure of the Web server is shown below:
import java.io.* ;
import java.net.* ;
import java.util.* ;
public final class WebServer
{
public static void main(S.
MCIS 6163 Assignment 1/MCIS 6163 Assignment 1.pdf
Assignment 1 – MCIS 6163
Building a Simple Web Client and a Multithreaded Web Server
Objectives
To understand client-server communication via sockets.
To gain exposure to the basic operations of a Web server and client.
To explore basic structures of HTTP messages.
Due: April 14, 2020 11:59pm
Project Description
In this project, you will be developing a multithreaded Web server and a simple web client. The Web
server and Web client communicate using a text-based protocol called HTTP (Hypertext Transfer
Protocol).
Requirements for the Web server
The server is able to handle multiple requests concurrently. This means the implementation is
multithreaded. In the main thread, the server listens to a specified port, e.g., 8080. Upon receiving an
HTTP request, the server sets up a TCP connection to the requesting client and serves the request in a
separate thread. After sending the response back to the client, it closes the connection.
The server is assumed to work with HTTP GET messages. If the requested file exists, the server
responds with “HTTP/1.1 200 OK” together with the requested page to the client, otherwise it sends a
corresponding error message, e.g., “HTTP/1.1 404 Not Found” or “HTTP/1.1 400 Bad Request”.
If running the server program using command line, the syntax should be:
server_code_name [<port_number>]
where the optional <port_number> is the port on which the server is listening to connections from
clients. If the port number is not entered, the default port 8080 is used.
You can test your Web server implementation on your local machine using a Web browser, e.g.,
Internet Explorer, Firefox, or Chrome. You need to specify the used port number within the URL, for
example,
http://localhost:8080/index.htm
If omitting the port number portion, i.e., 8080, the browser will use the default port 80.
The server should response with a default page when users do not enter a specific page in the URL,
for example,
http://localhost:8080/
It should also work when the request includes a path to the requested file, for example,
http://localhost:8080/path/to/file/example.htm
You should display/log the request and header lines of request messages on the server for the purpose
of debugging.
Requirements for the simple Web client
The client is able to connect to the server via a socket and to request a page on the server.
Upon receipt of the response message from the server, the client extracts and displays/logs the
message status, and then retrieves the page content from the message body.
If running the client program using command line, the syntax should be:
client_code_name <server_IPaddress/name> [<port_number>] [<requested_file_name>]
where the <server_IPaddress/name> is the IP address or name of the Web server, e.g., 127.0.0.1 or
localhost for the server running on the local machine. The optional < ...
MCIS 6163 Assignment 1/MCIS 6163 Assignment 1.pdf
Assignment 1 – MCIS 6163
Building a Simple Web Client and a Multithreaded Web Server
Objectives
To understand client-server communication via sockets.
To gain exposure to the basic operations of a Web server and client.
To explore basic structures of HTTP messages.
Due: April 14, 2020 11:59pm
Project Description
In this project, you will be developing a multithreaded Web server and a simple web client. The Web
server and Web client communicate using a text-based protocol called HTTP (Hypertext Transfer
Protocol).
Requirements for the Web server
The server is able to handle multiple requests concurrently. This means the implementation is
multithreaded. In the main thread, the server listens to a specified port, e.g., 8080. Upon receiving an
HTTP request, the server sets up a TCP connection to the requesting client and serves the request in a
separate thread. After sending the response back to the client, it closes the connection.
The server is assumed to work with HTTP GET messages. If the requested file exists, the server
responds with “HTTP/1.1 200 OK” together with the requested page to the client, otherwise it sends a
corresponding error message, e.g., “HTTP/1.1 404 Not Found” or “HTTP/1.1 400 Bad Request”.
If running the server program using command line, the syntax should be:
server_code_name [<port_number>]
where the optional <port_number> is the port on which the server is listening to connections from
clients. If the port number is not entered, the default port 8080 is used.
You can test your Web server implementation on your local machine using a Web browser, e.g.,
Internet Explorer, Firefox, or Chrome. You need to specify the used port number within the URL, for
example,
http://localhost:8080/index.htm
If omitting the port number portion, i.e., 8080, the browser will use the default port 80.
The server should response with a default page when users do not enter a specific page in the URL,
for example,
http://localhost:8080/
It should also work when the request includes a path to the requested file, for example,
http://localhost:8080/path/to/file/example.htm
You should display/log the request and header lines of request messages on the server for the purpose
of debugging.
Requirements for the simple Web client
The client is able to connect to the server via a socket and to request a page on the server.
Upon receipt of the response message from the server, the client extracts and displays/logs the
message status, and then retrieves the page content from the message body.
If running the client program using command line, the syntax should be:
client_code_name <server_IPaddress/name> [<port_number>] [<requested_file_name>]
where the <server_IPaddress/name> is the IP address or name of the Web server, e.g., 127.0.0.1 or
localhost for the server running on the local machine. The optional <.
This document discusses Java networking and client/server communication. A client machine makes requests to a server machine over a network using protocols like TCP and UDP. TCP provides reliable data transmission while UDP sends independent data packets. Port numbers map incoming data to running processes. Sockets provide an interface for programming networks, with ServerSocket and Socket classes in Java. A server program listens on a port for client connections and exchanges data through input/output streams. Servlets extend web server functionality by executing Java programs in response to client requests.
The document discusses Java networking concepts including sockets, TCP, UDP, client-server programming, and key networking classes like InetAddress, ServerSocket, Socket, DatagramSocket, and DatagramPacket. It provides code examples for basic TCP and UDP client-server applications in Java using sockets to demonstrate sending and receiving data over a network.
This document discusses creating network clients in Java. It covers creating sockets, implementing a generic network client, parsing data with StringTokenizer, retrieving files from HTTP servers and documents using URL class. It provides code for a generic network client, parsing strings with StringTokenizer, an address verifier client, and classes to retrieve URIs and URLs. It also briefly discusses talking to servers interactively and using the URL class to write a basic web browser.
1)Building a MultiThreaded Web ServerIn this lab we will develAgripinaBeaulieuyw
1)Building a MultiThreaded Web Server
In this lab we will develop a Web server in two steps. In the end, you will have built a multithreaded
Web server that is capable of processing multiple simultaneous service requests in parallel. You should be able to demonstrate
that your Web server is capable of delivering your home page to a Web browser.
We are going to implement version 1.0 of HTTP, as defined in RFC 1945, where separate HTTP requests are sent
for each component of the Web page. The server will be able to handle multiple simultaneous service requests in
parallel. This means that the Web server is multithreaded.
In the main thread, the server listens to a fixed port.
When it receives a TCP connection request, it sets up a TCP connection through another port and services the
request in a separate thread. To simplify this programming task, we will develop the code in two stages. In the first
stage, you will write a multithreaded
server that simply displays the contents of the HTTP request message that it
receives. After this program is running properly, you will add the code required to generate an appropriate response.
As you are developing the code, you can test your server from a Web browser. But remember that you are not
serving through the standard port 80, so you need to specify the port number within the URL that you give to your
browser. For example, if your machine's name is host.someschool.edu, your server is listening to port 6789, and
you want to retrieve the file index.html, then you would specify the following URL within the browser:
http://host.someschool.edu:6789/index.html
If you omit ":6789", the browser will assume port 80 which most likely will not have a server listening on it.
When the server encounters an error, it sends a response message with the appropriate HTML source so that the
error information is displayed in the browser window.
Web Server in Java: Part A
In the following steps, we will go through the code for the first implementation of our Web Server. Wherever you see
"?", you will need to supply a missing detail.
Our first implementation of the Web server will be multithreaded,
where the processing of each incoming request
will take place inside a separate thread of execution. This allows the server to service multiple clients in parallel, or
to perform multiple file transfers to a single client in parallel. When we create a new thread of execution, we need to
pass to the Thread's constructor an instance of some class that implements the Runnable interface. This is the
reason that we define a separate class called HttpRequest. The structure of the Web server is shown below:
import java.io.* ;
import java.net.* ;
import java.util.* ;
public final class WebServer
{
public static void main(String argv[]) throws Exception
{
. . .
}
}
final class HttpRequest implements Runnable
{
. . .
}
Normally, Web servers process service requests that they receive thr ...
Strategies for Effective Upskilling is a presentation by Chinwendu Peace in a Your Skill Boost Masterclass organisation by the Excellence Foundation for South Sudan on 08th and 09th June 2024 from 1 PM to 3 PM on each day.
Thinking of getting a dog? Be aware that breeds like Pit Bulls, Rottweilers, and German Shepherds can be loyal and dangerous. Proper training and socialization are crucial to preventing aggressive behaviors. Ensure safety by understanding their needs and always supervising interactions. Stay safe, and enjoy your furry friends!
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Main Java[All of the Base Concepts}.docxadhitya5119
This is part 1 of my Java Learning Journey. This Contains Custom methods, classes, constructors, packages, multithreading , try- catch block, finally block and more.
Assessment and Planning in Educational technology.pptxKavitha Krishnan
In an education system, it is understood that assessment is only for the students, but on the other hand, the Assessment of teachers is also an important aspect of the education system that ensures teachers are providing high-quality instruction to students. The assessment process can be used to provide feedback and support for professional development, to inform decisions about teacher retention or promotion, or to evaluate teacher effectiveness for accountability purposes.
This presentation was provided by Steph Pollock of The American Psychological Association’s Journals Program, and Damita Snow, of The American Society of Civil Engineers (ASCE), for the initial session of NISO's 2024 Training Series "DEIA in the Scholarly Landscape." Session One: 'Setting Expectations: a DEIA Primer,' was held June 6, 2024.
1. Tutorial 2 Network Programming in Java
Tutorial 2 Network Programming in Java
Objectives
Java network programming introduction
HTTP introduction
Java URL class for establishing HTTP connection
1
2. Tutorial 2 Network Programming in Java
1 Java network programming introduction
Java provides java.net package to support network
programming.
1.1 Client and Server
A client obtains a service via sending a request to a
server
A client initiates a connection, retrieves data, responds
user input. For example, web browser, chat program
(ICQ)
A server provides a set of services, such as web server,
time server, file server, chat server.
A server responds to connection, receives requests for
data from client, and delivers it to client.
The protocol between client and server is the
communication rule, for example FTP, SMTP, and
HTTP.
2
3. Tutorial 2 Network Programming in Java
1.2 Socket
We use socket to establish the connection between client
and server.
Socket identifies a connection using host address and port
number.
A socket is a bi-directional communication channel
Java differentiates client sockets from server sockets.
e.g. for client
Socket client=new Socket(“hostname”,portNumber);
for server
ServerSocket server=new SeverSocket(portNumber);
Client
port 13 Time Service
port 80 Web Service
Socket Socket
Server
3
4. Tutorial 2 Network Programming in Java
Well known ports for server
80 web server
21 Ftp server
13 Time server
23 Telnet
25 Email(SMTP)
1.3 The connection between server and client using
socket
Socket Operations at Client Side
create a client socket:
Socket (host, port)
s = new Socket (“java.sun.com”, 13)
get input / output data streams out of the socket:
in = new DataInputStream(s.getInputStream ());
out = new DataOutputStream( s.getOutputStream());
out = new PrintStream( s.getOutputStream());
read from input / write to output data streams:
String str = in.readLine();
out.println ( “Echo:” + str + “r”);
close the socket:
s.close();
4
5. Tutorial 2 Network Programming in Java
Socket Operations at Server Side
A server is always waiting for being connected. It
need not initiate a connection to a host. So a server
socket need only specify its own port no.
create a server socket:
ServerSocket (port)
ServerSocket s = new ServerSocket(8189);
accept an incoming connection:
Socket snew = s.accept ();
get input / output data streams out of the socket for
the incoming client:
in = new DataInputStream(snew.getInputStream());
out = new PrintStream(snew.getOutputStream());
close the socket for the incoming client:
snew.close();
1.4 Example : A web Client
import java.net.*;
import java.io.*;
class HttpClient {
public static void main(String[] args ) {
try {
Tutorial for CS5286 Algorithms&Tech for Web Search 5
6. Tutorial 2 Network Programming in Java
Socket s = new
Socket(quot;www.cs.cityu.edu.hkquot;,80);
DataInputStrea in = new
m
DataInputStream(s.getInputStream());
PrintStream out=new
PrintStream(s.getOutputStream());
out.println(quot;GET / HTTP/1.0quot;);
out.println();
String line;
while ((line=in.readLine())!=null)
System.out.println(quot;> quot;+line);
s.close();
} catch (Exception e)
{ System.out.println(e);}
}
}
2 HTTP introduction
HTTP( Hypertext Transfer Protocol) is an application
layer protocol , just like FTP, SMTP, etc. The WWW is
based on HTTP, for the communication rule between
the browser and web server is HTTP.
You can check following URL for detailed document about
HTTP . http://www.w3.org/Protocols/
Tutorial for CS5286 Algorithms&Tech for Web Search 6
7. Tutorial 2 Network Programming in Java
2.1 Overview
HTTP request
Format: Method URI HTTP Version
For example: GET / HTTP/1.0
There are three most important methods in HTTP 1.0 ,
include GET, PUT and HEAD
To request a web page, a browser sends a web server an
HTTP GET message
To send data to a web server, a browser can use an
HTTP POST message
To get information about document size , modification
date, but not document itself , you can use HTTP HEAD
request.
And there are some other HTTP methods added in HTTP
1.1 , such as PUT, DELETE, OPTIONS, and TRACE.
Also client can send additional information about itself to
web server, such as browser type, operation system.
HTTP response
Tutorial for CS5286 Algorithms&Tech for Web Search 7
8. Tutorial 2 Network Programming in Java
After receiving client’s request, web server will
respond. It includes web server HTTP version, HTTP
server status code for client’s request, and some
information about document, such as Content-Length,
Content-Type, Last-Modified date.
2. browser sends 3. server fetches web
1. user types or GET URL to page for URL
clicks URL server
4. server sends
web page data to
browser
5. browser
displays web
page*
internet
Tutorial for CS5286 Algorithms&Tech for Web Search 8
9. Tutorial 2 Network Programming in Java
2.2 Example
import java.net.*;
import java.io.*;
class HttpClient1 {
public static void main(String[] args ) {
try {
Socket s = new Socket(quot;www.cs.cityu.edu.hkquot;, 80);
DataInputStream in = new
DataInputStream(s.getInputStream());
PrintStream out=new PrintStream(s.getOutputStream());
out.println(quot;HEAD /index.html HTTP/1.0quot;);
out.println();
String line;
while ((line=in.readLine())!=null)
System.out.println(quot;> quot;+line);
s.close();
} catch (Exception e) { System.out.println(e);}
}
}
Tutorial for CS5286 Algorithms&Tech for Web Search 9
10. Tutorial 2 Network Programming in Java
2.3 URL: Uniform Resource Locator
The URL standard defines a common way to refer to
any web page, anywhere on the web
format: protocol://web_server_name/page_name
example: http://www.yahoo.com/index.html
URLs are most commonly used in conjunction with
the HTTP protocol to GET a URL, or POST data to a
URL
a URL can refer to many kinds of web page:
plain text, formatted text (usually in HTML…),
multimedia, database, ...
2.4 HTML: HypeText Markup Language
•Specific mark-up language used in the Web
•Many kinds of markups
–low-level appearance (font changes, lists)
–logical structure (title, headings)
–links to other documents
–embedded graphics
–meta-information (language)
Tutorial for CS5286 Algorithms&Tech for Web Search 10
11. Tutorial 2 Network Programming in Java
–and much more...
A simple HTML file
<HTML>
<HEAD>
<TITLE>
A HTML to test applet
</TITLE>
</HEAD>
<BODY>
<applet code=quot;HelloKitty2.classquot; Width=quot;80quot;
Height=quot;100quot;>
</applet>
</BODY>
</HTML>
Tutorial for CS5286 Algorithms&Tech for Web Search 11
12. Tutorial 2 Network Programming in Java
3 Java URL class
Java provides URL class to make it much easier to deal
with HTTP connection. We don’t need to care about low
layer socket connection.
You can find detailed information about them on following
URL,
http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html
3.1 URL
Constructor
URL(String spec)
Creates a URL object from the String representation.
URL(String protocol, String host, int port, String file)
Creates a URL object from the specified protocol, host, port number, and file.
URL(String protocol, String host, int port, String file, URLStreamHandler handler)
Creates a URL object from the specified protocol, host, port number, file, and handler.
URL(String protocol, String host, String file)
Creates a URL from the specified protocol name, host name, and file name.
URL(URL context, String spec)
Creates a URL by parsing the given spec within a specified context.
URL(URL context, String spec, URLStreamHandler handler)
Creates a URL by parsing the given spec with the specified handler wit in a specified
h
context.
Excetption
MalformedURLException
Thrown if you try to create a bogus URL
Usually means bad user input, so fail
gracefully and informatively
Tutorial for CS5286 Algorithms&Tech for Web Search 12
13. Tutorial 2 Network Programming in Java
accessor methods
getProtocol(), getHost(), getPort(),
getFile(), getRef()
openConnection()
public URLConnection openConnection() throws
IOException
Returns a URLConnection object that
represents a connection to the remote
object referred to by the URL.
If there is not already an open
connection, the connection is opened by
calling the openConnection method of the
protocol handler for this URL.
OpenStream()
public final InputStream openStream() throws
IOException
Opens a connection to this URL and returns
an InputStream for reading from that
connection. This method is a shorthand for:
openConnection().getInputStream()
getContent
public final Object getContent() throws IOException
Returns the contents of this URL. This method is a shorthand for:
openConnection().getContent()
Tutorial for CS5286 Algorithms&Tech for Web Search 13
14. Tutorial 2 Network Programming in Java
Example 1
import java.net.*;
public class UrlTest {
public static void main(String[] args) {
if (args.length == 1) {
try {
URL url = new URL(args[0]);
System.out.println
(quot;URL: quot; + url.toExternalForm() + quot;nquot; +
quot; File: quot; + url.getFile() + quot;nquot; +
quot; Host: quot; + url.getHost() + quot;nquot; +
quot; Port: quot; + url.getPort() + quot;nquot; +
quot; Protocol: quot; + url.getProtocol() + quot;nquot; +
quot; Reference: quot; + url.getRef());
} catch(MalformedURLException mue) {
System.out.println(quot;Bad URL.quot;);
}
} else
System.out.println(quot;Usage: UrlTest <URL>quot;);
}
}
Tutorial for CS5286 Algorithms&Tech for Web Search 14
15. Tutorial 2 Network Programming in Java
Example 2 was given in Tutorial 1.
Using openStream()
Example 3 Using getContent()
import java.net.*;
import java.io.*;
public class UrlRetriever1 {
public static void main(String[] args) {
checkUsage(args);
try {
URL url=new URL(args[0]);
DataInputStream in= new
DataInputStream((InputStream)url.getContent());
String line;
while ((line=in.readLine())!=null)
System.out.println(line);
in.close();
} catch(MalformedURLException mue)
{ System.out.println(args[0]+quot;is an invalid URL:quot;+mue);
} catch(IOException ioe) {
System.out.println(quot;IOException: quot;+ioe);
}
}
private static void checkUsage(String[] args) {
if (args.length!=1) {
System.out.println(quot;Usage: UrlRetriever2 <URL>quot;);
System.exit(-1);
}
}
}
Tutorial for CS5286 Algorithms&Tech for Web Search 15
16. Tutorial 2 Network Programming in Java
4 Exercises
Implement a HTTP server (Simulated) using
ServerSocket.
Using URL Class, write a http client to retrieve
http://www.cs.cityu.edu.hk/index.html, and return the
last modified date, Content-Length, Content-Type of this
web page.
Tutorial for CS5286 Algorithms&Tech for Web Search 16