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.

Slides:



Advertisements
Similar presentations
Socket Programming ENTERPRISE JAVA. 2 Content  Sockets  Streams  Threads  Readings.
Advertisements

COEN 445 Communication Networks and Protocols Lab 4
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.
CHATROOM PROJECT Supervised by DAN WITZNER HANSEN Group Members ESWAR EMMADI SURESH KUMAR DONTHA.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
Network Programming CS3250. References Core Java, Vol. II, Chapter 3. Book examples are available from
Programming project #4 1 CS502 Spring 2006 Programming Project #4 Web Server CS-502 Operating Systems Spring 2006.
Stromchat Extendable, Modable, Multifunction Peer-to-Peer Chat Server/Client.
A Chat Server DBI – Representation and Management of Data on the Internet.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L22 (Chapter 25) Networking.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
B. Prabhakaran 1 Project 1 Notes Not familiar with threads & sockets? Try building separate programs Program 1A Use Threads alone, no sockets Design a.
CS-3103 & CS-502, Summer 2006 Programming Project #31 Programming Project #3 Web Server CS-3103 & CS-502 Operating Systems.
Chat Room Project (IM- E2003) Supervised by : Dan Witzner Hansen Group Member: Xijie Lu Vu Pham To IT University of Copenhagen 23rd Jan.2004.
Aalborg Media Lab 15-Jul-15 Java & EyesWeb Lecture 14 Java Client / Server Communication.
CEG3185 Tutorial 4 Prepared by Zhenxia Zhang Revised by Jiying Zhao (2015w)
Web Proxy Server. Proxy Server Introduction Returns status and error messages. Handles http CGI requests. –For more information about CGI please refer.
TCP Sockets Reliable Communication. TCP As mentioned before, TCP sits on top of other layers (IP, hardware) and implements Reliability In-order delivery.
Socket Programming in Java -First Step of Network Programming-
By: Joel Rodriguez.  International student from Mexico  Delicias, Chihuahua Mexico  Spanish  Sports and Music.
TCP/IP protocols Communication over Internet is mostly TCP/IP (Transmission Control Protocol over Internet Protocol) TCP/IP "stack" is software which allows.
FTP (File Transfer Protocol) & Telnet
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Networking COMP # 21.
Lab 6: Introduction to Sockets (Web Programming – Part 1) Reference: Head First Java (2 nd Edition) by Kathy Sierra & Bert Bates.
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
Mark Fontenot CSE Honors Principles of Computer Science I Note Set 11.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
RGEC MEERUT(IWT CS703) 1 Java Networking RGEC Meerut.
1 Rick Mercer Multi Threaded Chat Server. 2 Client – Server with Socket Connections We've seen how to establish a connection with 1 client Review a simple.
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.
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.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Networking COMP # 22.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Networking and Concurrency COMP.
CS390- Unix Programming Environment CS 390 Unix Programming Environment Java Socket Programming.
CS 158A1 1.4 Implementing Network Software Phenomenal success of the Internet: – Computer # connected doubled every year since 1981, now approaching 200.
Java Sockets Tutorial Rahul Malik Nov 12, 2005.
VII. Sockets. 1. What is a Socket? A socket is one end-point of a two-way communication link between two programs running on the network. Socket classes.
CSC 480 Software Engineering Socket. What is Socket? A socket is one end-point of a two-way communication link between two programs running on the network.
Field Trip #25 Creating a Client/Server By Keith Lynn.
Tips.  Your system should be robust and easy to use.  Display meaningful text, mention units & assumptions (maybe as a tool-tip).  Use meaningful error.
Prepared by Dr. Jiying Zhao University of Ottawa Canada.
Socket Programming in Java -First Step of Network Programming-
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Agenda Socket Programming The OSI reference Model The OSI protocol stack Sockets Ports Java classes for sockets Input stream and.
Java Networking I IS Outline  Quiz #3  Network architecture  Protocols  Sockets  Server Sockets  Multi-threaded Servers.
Networking OSI (Open Systems Interconnection) model of computer networking, seven layers (the Application, Presentation, Session, Transport, Network, Data.
A Local Area Network Chat Client ITTC LAN CHAT John Vincent Cecogo Jerikho Daguno Ardee Santos Elaine Mendoza Anjomar Pat Del Mindo Philip John Sales Philip.
Li Tak Sing COMPS311F. Case study: a multithreaded chat server The source contains 3 files: ChatServer //the chat server ChatThread //the thread on the.
Mac OS X backdoor Trojan, now in beta? 報告人:劉旭哲. Introduction It targets users of Mac OS X As even the malware itself admits, it is not yet finished. It.
CLIENT (Browser) socket accept C1 C2 recv C2 recv send C2 send end_thread recv C3 send bind connect Web Server Proxy recv close C3 close C2 end_thread.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
The Echo Server Problem. Contents  Basic Networking Concepts  The Echo Server Problem.
The Echo Server Problem. Contents  Basic Networking Concepts  The Echo Server Problem.
The Chat Problem.
Echo Networking COMP
CSC410: Distributed System
Networking COMP
Client-server Programming
Socket Programming Cal Poly Pomona Young CS380.
Java Socket Programming and Java RMI CS
EE 422C Socket Programming
Clients and Servers 19-Nov-18.
Clients and Servers 1-Dec-18.
Software Engineering for Internet Applications
TA: Donghyun (David) Kim
Java Socket Programming and Java RMI CSE 291
Clients and Servers 19-Jul-19.
Clients and Servers 13-Sep-19.
Presentation transcript:

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 This is not a problem if the two programs are on different machines. Socket and ServerSocket are unrelated classes—neither extends the other You can't successfully set up a client Socket unless there is a server running A client Socket cannot accept() a message; only a ServerSocket can do that A ServerSocket cannot send a message; only a client Socket can do that The only way to get a client Socket from a ServerSocket is to accept() a message Once a Reader has read in a message, it apparently can’t be used again

3 A successful approach, I Try to set up a server on port #1 If successful (i.e. you don’t get an exception), Set output port = port #2 else Set up a server on port #2 Set output port = port #1 Create a thread to listen to (accept messages from) the server port

4 A successful approach, II The listener for user input creates a writer for the output port and writes to it It also copies the text to the display area, and clears the text input area for future use It should be possible to use the same writer every time, but that doesn’t seem to work for me The run() method accepts the message, creates a reader for it, and reads and displays the message As long as you know all input comes from the same port, it should be possible to use the same reader every time; but even if you can make this work, it probably isn’t a good idea

5 The End