1 L54 Networking (3). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.

Slides:



Advertisements
Similar presentations
28.2 Functionality Application Software Provides Applications supply the high-level services that user access, and determine how users perceive the capabilities.
Advertisements

Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
Real-Time Authentication Using Digital Signature Schema Marissa Hollingsworth BOISECRYPT ‘09.
Socket Programming.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
1 Java Networking – Part I CS , Spring 2008/9.
1 L52 Networking (1). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
1 L55 Networking (4). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
 Pearson Education, Inc. All rights reserved. 1 CH24 Networking : OBJECTIVES In this chapter you will learn:  To understand Java networking.
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
Networking Support In Java 2 Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Network Programming CS3250. References Core Java, Vol. II, Chapter 3. Book examples are available from
1 Programming Section 9 James King 12 August 2003.
CS 311 – Lecture 18 Outline IPC via Sockets – Server side socket() bind() accept() listen() – Client side connect() Lecture 181CS Operating Systems.
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.
Online Chess Project 3 Due date: April 17 th. Introduction Third in series of three projects This project focuses on adding online support –2 players.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L22 (Chapter 25) Networking.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
© Lethbridge/Laganière 2001 Chap. 3: Basing Development on Reusable Technology 1 Let’s get started. Let’s start by selecting an architecture from among.
 Pearson Education, Inc. All rights reserved Networking.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
Networking Support In Java 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
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.
Computer Networking From LANs to WANs: Hardware, Software, and Security Chapter 16 Writing a Network Application.
By: Joel Rodriguez.  International student from Mexico  Delicias, Chihuahua Mexico  Spanish  Sports and Music.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 3 Inter-process Communication.
Hands On Networking Socket Programming Ram P Rustagi, ISE Dept Abhishek Gupta, ISE Dept Laxmi Kuber, MCA Dept June 28-30, 2012.
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.
CS4273: Distributed System Technologies and Programming Lecture 13: Review.
Outline Overview Video Format Conversion Connection with An authentication Streaming media Transferring media.
Chapter 18 Networking F Client/Server Communications F Simple Client/Server Applications F Serve Multiple Clients F Create Applet Clients F Send and Retrieve.
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
ICOM 6115©Manuel Rodriguez-Martinez ICOM 6115 – Computer Networks and the WWW Manuel Rodriguez-Martinez, Ph.D. Lecture 26.
 TCP (Transport Control Protocol) is a connection-oriented protocol that provides a reliable flow of data between two computers.  TCP/IP Stack Application.
Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.
© Lethbridge/Laganière 2005 Chap. 3: Basing Development on Reusable Technology The Client-Server Architecture A distributed system is a system in.
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.
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
Sockets Sockets A socket is an object that encapsulates a TCP/IP connection There is a socket on both ends of a connection, the client side and the server.
 2005 Pearson Education, Inc. All rights reserved Networking.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
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.
Socket Programming.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Networking A network represents interconnection of computers that is capable.
Acknowledgement: These slides are adapted from slides provided in Thißen & Spaniol's course Distributed Systems and Middleware, RWTH Aachen Processes Distributed.
Networking with JavaN-1 Outline Client-Server Example Steps required on the server side Steps required on the client side.
Advanced Java Session 4 New York University School of Continuing and Professional Studies.
Networked Graphics Building Networked Virtual Environments and Networked Games Chapter 2: One on one (101)
Socket programming in C. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
Java How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Java Networking I IS Outline  Quiz #3  Network architecture  Protocols  Sockets  Server Sockets  Multi-threaded Servers.
Threads CS 21b. Threads in Java zDefinition Õunit of program control that represents an execution sequence zJava supports multi-threaded execution * Programs.
SOCKET PROGRAMMING WITH JAVA By Collin Donaldson.
1 Network Communications A Brief Introduction. 2 Network Communications.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 29 Remote Method.
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 Echo Server Problem. Contents  Basic Networking Concepts  The Echo Server Problem.
Chapter 18 Networking Client/Server Communications
24 Networking.
Chapter 40 Remote Method Invocation
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
Presentation transcript:

1 L54 Networking (3)

2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java networking applications by using sockets and datagrams.  To understand how to implement Java clients and servers that communicate with one another.  To understand how to implement network-based collaborative applications.  To construct a multithreaded server.

Client/Server Tic-Tac-Toe Using a Multithreaded Server Multiple threads – Server uses one thread per player Allow each player to play game independently

4 Outline TicTacToeServer.java (1 of 12)

5 Outline TicTacToeServer.java (2 of 12)

6 Outline TicTacToeServer.java (3 of 12) Line 50 Line 55 Create array players with 2 elements Create ServerSocket to listen on port 12345

7 Outline TicTacToeServer.java (4 of 12) Lines Line 79 Line 80 Loop twice, blocking at line 79 each time while waiting for a client connection Create a new Player object to manage the connection as a separate thread Execute the Player in the runGame thread pool

8 Outline TicTacToeServer.java (5 of 12)

9 Outline TicTacToeServer.java (6 of 12)

10 Outline TicTacToeServer.java (7 of 12)

11 Outline TicTacToeServer.java (8 of 12) Lines Get the streams to send and receive data

12 Outline TicTacToeServer.java (9 of 12) Lines Line 215 Lines Format output notifying the other player of the move Call Formatter method flush to force the output to the client Send player’s mark

13 Outline TicTacToeServer.java (10 of 12) Lines Lines Send message indicating one player connected and waiting for another player to arrive Begin the game

14 Outline TicTacToeServer.java (11 of 12) Lines Line 269 Lines 272 Lines Send message indicating player O connected Read a moveCheck the moveSend message indicating the move is valid

15 Outline TicTacToeServer.java (12 of 12) Lines Send message indicating the move is invalid

16 Outline TicTacToeServer Test.java Program output

17 Outline TicTacToeClient.java (1 of 10)

18 Outline TicTacToeClient.java (2 of 10)

19 Outline TicTacToeClient.java (3 of 10)

20 Outline TicTacToeClient.java (4 of 10) Lines Lines Line 105 Connect to the serverGet the streams to send and receive data Read mark character from server

21 Outline TicTacToeClient.java (5 of 10) Lines Lines Lines Loop continually Read and process messages from server If valid move, write message and set mark in square

22 Outline TicTacToeClient.java (6 of 10) Lines Lines If invalid move, display message If opponent moves, set mark in square

23 Outline TicTacToeClient.java (7 of 10)

24 Outline TicTacToeClient.java (8 of 10) Lines Send the move to the server

25 Outline TicTacToeClient.java (9 of 10)

26 Outline TicTacToeClient.java (10 of 10)

27 Outline TicTacToeClient Test.java

 2005 Pearson Education, Inc. All rights reserved. 28 Fig | Sample outputs from the client/server Tic-Tac-Toe program. (Part 1 of 2.)

 2005 Pearson Education, Inc. All rights reserved. 29 Fig | Sample outputs from the client/server Tic-Tac-Toe program. (Part 2 of 2.)

Security and the Network By default, applets cannot perform file processing Applets often limited in machine access – Applets can communicate only with the machine from which it was originally downloaded Java Security API – Digitally signed applets – Applets given more privileges if from trusted source