The Echo Server Problem. Contents  Basic Networking Concepts  The Echo Server Problem.

Slides:



Advertisements
Similar presentations
Sockets Tutorial Ross Shaull cs146a What we imagine Network request… response… The packets that comprise your request are orderly.
Advertisements

COEN 445 Communication Networks and Protocols Lab 4
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
Skills: none Concepts: Web client (browser), Web server, network connection, URL, mobile client, protocol This work is licensed under a Creative Commons.
Prepared By: Eng. Ola M. Abd El-Latif May/2010.  In this Lab we will answer the most frequently asked questions about programming sockets in Java. 
1 L54 Networking (3). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
Basic Socket Programming with Java. What is a socket?  Generally refers to a stream connecting processes running in different address spaces (across.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
IT skills: IT concepts: Web client (browser), Web server, network connection, URL, mobile client, peer-to- peer application This work is licensed under.
Network Programming CS3250. References Core Java, Vol. II, Chapter 3. Book examples are available from
System Programming Practical session 10 Java sockets.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L24 (Chapter 25) Networking.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L23 (Chapter 25) Networking.
Week 2 IBS 685. Static Page Architecture The user requests the page by typing a URL in a browser The Browser requests the page from the Web Server The.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L22 (Chapter 25) Networking.
Definitions, Definitions, Definitions Lead to Understanding.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
HTTP Overview Vijayan Sugumaran School of Business Administration Oakland University.
Networking with Java CSc 335 Object-Oriented Programming and Design Spring 2009.
Chapter 26 Client Server Interaction Communication across a computer network requires a pair of application programs to cooperate. One application on one.
19-Aug-15 About the Chat program. 2 Constraints You can't have two programs (or two copies of the same program) listen to the same port on the same machine.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Lightning Talk Fred Rodriguez Aakash Juneja CPSC 473 March 16, 2012.
Network Layer Programing Connection-Oriented Sockets SWE 344 Internet Protocols & Client Server Programming.
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
Introduction to Interprocess communication SE-2811 Dr. Mark L. Hornick 1.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
Lab 6: Introduction to Sockets (Web Programming – Part 1) Reference: Head First Java (2 nd Edition) by Kathy Sierra & Bert Bates.
Chapter 18 Networking F Client/Server Communications F Simple Client/Server Applications F Serve Multiple Clients F Create Applet Clients F Send and Retrieve.
Data Streams David Meredith Source Chapter 19 of – Shiffman, D. (2008). Learning Processing. Morgan Kaufmann, Burlington, MA. ISBN:
1. I NTRODUCTION TO N ETWORKS Network programming is surprisingly easy in Java ◦ Most of the classes relevant to network programming are in the java.net.
Chapter 2 Applications and Layered Architectures Sockets.
1 Chapter 28 Networking. 2 Objectives F To comprehend socket-based communication in Java (§28.2). F To understand client/server computing (§28.2). F To.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Networking and Concurrency COMP.
ECEN “Internet Protocols and Modeling”, Spring 2012 Course Materials: Papers, Reference Texts: Bertsekas/Gallager, Stuber, Stallings, etc Class.
Distributed Computing A Programmer’s Perspective.
Position of application layer. Application layer duties.
Java Programming: Advanced Topics 1 Networking Programming Chapter 11.
© 2009 Research In Motion Limited Advanced Java Application Development for the BlackBerry Smartphone Trainer name Date.
Field Trip #25 Creating a Client/Server By Keith Lynn.
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl1 1 Chapter 15 Application Layer and Client-Server.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Networking A network represents interconnection of computers that is capable.
TCP/IP Protocol Stack IP Device Drivers TCPUDP Application Sockets (Gate to network) TCP: –Establish connection –Maintain connection during the communication.
©The McGraw-Hill Companies, Inc., 2000© Adapted for use at JMU by Mohamed Aboutabl, 2003Mohamed Aboutabl1 1 Chapter 16 Socket Interface.
COMP2322 Lab 4 Socket Programming Toby Lam March 2, 2016.
Java Networking I IS Outline  Quiz #3  Network architecture  Protocols  Sockets  Server Sockets  Multi-threaded Servers.
Java’s networking capabilities are declared by the classes and interfaces of package java.net, through which Java offers stream-based communications that.
A Web Based Job Submission System for a Physics Computing Cluster David Jones IOP Particle Physics 2004 Birmingham 1.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
Sending . Contents A)Sending Mail Using Command Line B)Sending Mail Using GUI.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 33 Networking.
The Echo Server Problem. Contents  Basic Networking Concepts  The Echo Server Problem.
The Chat Problem.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Regular Expressions.
Internationalization The Number Format Problem
Echo Networking COMP
The Bouncing Ball Problem (Independent Threads)
CSC410: Distributed System
MCA – 405 Elective –I (A) Java Programming & Technology
Beyond HTTP Up to this point we have been dealing with software tools that run on browsers and communicate to a server that generates files that can be.
More About Threads.
Chapter 18 Networking Client/Server Communications
Socket Programming Cal Poly Pomona Young CS380.
Starting TCP Connection – A High Level View
Software Engineering and Architecture
Message Passing Systems Version 2
Message Passing Systems
Presentation transcript:

The Echo Server Problem

Contents  Basic Networking Concepts  The Echo Server Problem

I. Basic Networking Concepts  Connection-Oriented Service  Port  Socket

1. Connection-Oriented Server User establishes a connection and maintains that connection This is in contrast to the Web, where the protocol is transactional – the browser asks for a page, and the server sends it; the connection is then closed

2. Port A port is not a physical device, it is just a number that identifies a specific program on the server  Port numbers from 0 to 1023 are reserved for well-known services. Don’t use them for your own server programs!  If you’re writing services (server programs) to run on a company network, you should check with the sys-admins to find out which ports are already taken

3. Socket A socket is an abstraction for the network software that enables communication out of and into this program  It represents a network connection between two machines  It contains two streams, one is for reading data coming in, and the other is for writing data out

II. The Echo Server Problem Develop a simple server that listens to port 8189 and echoes back all client's input

Solution  Main Class to Start the Echo Server  Developing EchoServer Class to Serve One Client at a Time  Improving EchoServer to Serve Multiple Clients at the Same Time

1. Main Class to Start the Echo Server

2. Developing EchoServer Class to Serve One Client at a Time 2.1. Getting Ready to Receive Incoming Connections 2.2. Waiting Indefinitely for a Connection to Come In 2.3. Serving the Client

2.1. Getting Ready to Receive Incoming Connections

2.2. Waiting Indefinitely for a Connection to Come In

2.3. Serving the Client The try-finally Template Checking Whether the Client has Sent a Message Echoing the Message to the Client Returning If the Client Stops Sending

The try-finally Template

Checking Whether the Client has Sent a Message

Echoing the Message to the Client

Returning If the Client Stops Sending

3. Improving EchoServer to Serve Multiple Clients at the Same Time At this moment, the program can serve only one client at a time. Furthermore, after serving that client, the service is closed down 3.1. Making the EchoServer Run Forever 3.2. Serving a Client in a Separate Thread

3.1. Making the EchoServer Run Forever

3.2. Serving a Client in a Separate Thread

The Client Develop a simple client that connects to port 8189 of the server, sends and receive data back from the server.

Solution  Main Class to Start the Echo Client  Developing EchoClient Class to Send and Receive from the Server

1. Main Class to Start the Echo Client

2. Developing EchoClient Class 2.1. Constructing a Socket to Connect to the Echo Server 2.2. Getting Input and Output Streams of the Socket 2.3. Getting Data from the Console, Sending and Retrieving from the Socket.

2.1. Constructing a Socket to Connect to the Echo Server

2.2. Getting Input and Output Streams of the Socket

2.3. Getting Data from the Console, Sending and Retrieving from the Socket

References  Core Java, Volume II – Advanced Features, Eighth Edition, Chapter 3. Cay S. Horstmann and Gary Cornell. Prentice Hall, 2008  Building a Java chat server. Greg Travis. ibm.com/developerWorks