Generic Connection Framework Connection FileConnectionSocketConnectionHTTPConnection InputConnection OutputConnection StreamConnection.

Slides:



Advertisements
Similar presentations
Network Programming and Java Sockets
Advertisements

Inter-Process Communication: Network Programming using TCP Java Sockets Dr. Rajkumar Buyya Cloud Computing and Distributed Systems (CLOUDS) Laboratory.
1 Network Programming and Java Sockets Rajkumar Buyya Grid Computing and Distributed Systems (GRIDS) Laboratory Dept. of Computer Science and Software.
Socket Programming ENTERPRISE JAVA. 2 Content  Sockets  Streams  Threads  Readings.
Socket Programming By Ratnakar Kamath. What Is a Socket? Server has a socket bound to a specific port number. Client makes a connection request. Server.
© Amir Kirsh Java Networking Written by Amir Kirsh, Edited by Liron Blecher.
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 Java Networking – Part I CS , Spring 2008/9.
Network Programming CS3250. References Core Java, Vol. II, Chapter 3. Book examples are available from
CIS – Spring Instructors: Geoffrey Fox, Bryan Carpenter Computational Science and.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L22 (Chapter 25) Networking.
Generic Connection Framework Connection FileConnectionSocketConnectionHTTPConnection InputConnection OutputConnection StreamConnection.
Socket Communication Sockets provide an abstraction of two-point communication The two sides only read/write without concern for how data is translated.
1 Fall 2005 Socket Programming Qutaibah Malluhi Computer Science and Engineering Qatar University.
Network Programming and Java Sockets 1 Dr. Christian Vecchiola Postdoctoral Research Fellow Cloud Computing and Distributed Systems.
Network/Socket Programming in Java Rajkumar Buyya.
CEG3185 Tutorial 4 Prepared by Zhenxia Zhang Revised by Jiying Zhao (2015w)
Socket Programming in Java -First Step of Network Programming-
Greg Jernegan Brandon Simmons. The Beginning…  The problem Huge demand for internet enabled applications and programs that communicate over a network.
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.
SOCKET PROGRAMMING. Client/Server Communication At a basic level, network-based systems consist of a server, client, and a media for communication as.
NET0183 Networks and Communications Lecture 31 The Socket API 8/25/20091 NET0183 Networks and Communications by Dr Andy Brooks Lecture powerpoints from.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 12 Communicating over.
DBI Representation and Management of Data on the Internet.
1 CSCD 330 Network Programming Winter 2015 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 6 Application.
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.
Object Oriented Programming in Java Lecture 16. Networking in Java Concepts Technicalities in java.
© Amir Kirsh Java Networking Written by Amir Kirsh.
Lecture 9 Network programming. Manipulating URLs URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on the Internet.
Li Tak Sing COMPS311F. Case study: consumers and producers A fixed size buffer which can hold at most certain integers. A number of producers which generate.
1 Network Programming and Java Sockets. 2 Network Request Result a client, a server, and network Client Server Client machine Server machine Elements.
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
Web Design & Development 1 Lec - 21 Umair Javed. Web Design & Development 2 Socket Programming.
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.
Socket-Programming.  Establish contact (connection).  Exchange information (bi-directional).  Terminate contact.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Networking COMP # 22.
Networks Sockets and Streams. TCP/IP in action server ports …65535 lower port numbers ( ) are reserved port echo7 time13 ftp20 telnet23.
1 cs205: engineering software university of virginia fall 2006 Network Programming* * Just enough to make you dangerous Bill Cheswick’s map of the Internet.
Networking Terminology: ISP (Internet service provider) – dialup, dsl, cable LAN (local area network) IP (internet protocol) address, eg
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 15 IO Using http Rob Pooley
Introduction to Java Network Programming and HTTP
Network Programming All networked computers have an IP Address – Unique – In the form of xxx.xxx.xxx.xxx ( ) – 32 bits = ~4 billion possibilities.
By Vivek Dimri. Basic Concepts on Networking IP Address – Protocol – Ports – The Client/Server Paradigm – Sockets The Java Networking Package – The InetAddress.
TCP/IP Protocol Stack IP Device Drivers TCPUDP Application Sockets (Gate to network) TCP: –Establish connection –Maintain connection during the communication.
Simple Socket Server m Yumiko Kimezawa September 19, 20121RPS.
Prepared by Dr. Jiying Zhao University of Ottawa Canada.
UNIT-6. Basics of Networking TCP/IP Sockets Simple Client Server program Multiple clients Sending file from Server to Client Parallel search server.
Java Programming II Java Network (I) Java Programming II.
1 Lecture 9: Network programming. 2 Manipulating URLs URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on.
Socket Programming in Java -First Step of Network Programming-
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
LeJOS Protocols. Serial Class Serial class found in josx.platform.rcx package Serial class found in josx.platform.rcx package RCX – IR, RCX – RCX communication.
Network Programming with Java java.net.InetAddress: public static void main(String[] args) throws UnknownHostException { InetAddress localAddress = InetAddress.getLocalHost();
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Java API for distributed computing.
Networking OSI (Open Systems Interconnection) model of computer networking, seven layers (the Application, Presentation, Session, Transport, Network, Data.
Li Tak Sing COMPS311F. Case study: a multithreaded chat server The source contains 3 files: ChatServer //the chat server ChatThread //the thread on the.
SOCKET PROGRAMMING WITH JAVA By Collin Donaldson.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
Java 13. Networking public class SumTest {
Echo Networking COMP
Lecture 21 Sockets 1 (Not in D&D) Date.
Clients and Servers 19-Nov-18.
Clients and Servers 1-Dec-18.
Chapter 2: Application layer
Clients and Servers 19-Jul-19.
Clients and Servers 13-Sep-19.
Presentation transcript:

Generic Connection Framework Connection FileConnectionSocketConnectionHTTPConnection InputConnection OutputConnection StreamConnection

Generic Connection Framework Connection FileConnectionSocketConnectionHTTPConnection InputConnection OutputConnection StreamConnection void close()

Generic Connection Framework Connection FileConnectionSocketConnectionHTTPConnection InputConnection OutputConnection StreamConnection void close() DIS openDataInputStream() DIS openInputStream() DOS openDataOutputStream() DOS openOutputStream()

Generic Connection Framework Connection FileConnectionSocketConnectionHTTPConnection InputConnection OutputConnection StreamConnection void close() DIS openDataInputStream() DIS openInputStream() DOS openDataOutputStream() DOS openOutputStream() String getAddress() String getLocalAddress() int getLocalPort() int getPort()

Socket Communication  Sockets provide an abstraction of two-point communication  The two sides only read/write without concern for how data is translated (encoded) and transmitted

Socket Communication  Sockets provide an abstraction of two-point communication  The two sides only read/write without concern for how data is translated (encoded) and transmitted  Socket is a pair (address, port)  address: turing.cc.gettysburg.edu,  port: 21 (ftp), 22 (ssh), 23 (telnet), 80 (http), 101 (pop mail)

Socket Communication server (turing.cc.gettysburg.edu) client ( ) web server listens on port 80

Socket Communication server (turing.cc.gettysburg.edu) client ( )request web page turing.cc…:80 socket :1234 web server listens on port 80

Socket Communication server (turing.cc.gettysburg.edu) client ( )request web page turing.cc…:80 socket :1234 socket tuing.cc…..:5789 accept request web server listens on port 80

Socket Communication server (turing.cc.gettysburg.edu) client ( ) socket :1234 socket tuing.cc…..:5789 web server listens on port 80

Socket Communication server (turing.cc.gettysburg.edu) client ( ) socket :1234 socket tuing.cc…..:5789 web server listens on port 80 client ( )request web page turing.cc…:80 socket :1024

Socket Communication server (turing.cc.gettysburg.edu) client ( ) socket :1234 socket tuing.cc…..:5789 web server listens on port 80 client ( )request web page turing.cc…:80 socket :1024 socket tuing.cc…..:8019 accept request

Socket Communication server (turing.cc.gettysburg.edu) client ( ) socket :1234 socket tuing.cc…..:5789 web server listens on port 80 client ( ) socket :1024 socket tuing.cc…..:8019

Simple Server (one client) 1.Open the Server Socket 2.Wait for Client Request 3.Create Streams for Communication 4.Carry Out Communication 5.Close Communication

Simple Server (one client) 1.Open the Server Socket ServerSocket server = new ServerSocket(5678); 2.Wait for Client Request 3.Create Streams for Communication 4.Carry Out Communication 5.Close Communication

Simple Server (one client) 1.Open the Server Socket ServerSocket server = new ServerSocket(5678); 2.Wait for Client Request Socket connection = server.accept(); 3.Create Streams for Communication 4.Carry Out Communication 5.Close Communication

Simple Server (one client) 1.Open the Server Socket ServerSocket server = new ServerSocket(5678); 2.Wait for Client Request Socket connection = server.accept(); 3.Create Streams for Communication OutputStream os = connection.getOutputStream(); DataOutputStream output = new DataOutputStream (os); 4.Carry Out Communication 5.Close Communication

Simple Server (one client) 1.Open the Server Socket ServerSocket server = new ServerSocket(5678); 2.Wait for Client Request Socket connection = server.accept(); 3.Create Streams for Communication OutputStream os = connection.getOutputStream(); DataOutputStream output = new DataOutputStream (os); 4.Carry Out Communication output.writeUTF("Hi there"); 5.Close Communication

Simple Server (one client) 1.Open the Server Socket ServerSocket server = new ServerSocket(5678); 2.Wait for Client Request Socket connection = server.accept(); 3.Create Streams for Communication OutputStream os = connection.getOutputStream(); DataOutputStream output = new DataOutputStream (os); 4.Carry Out Communication output.writeUTF("Hi there"); 5.Close Communication output.close(); os.close(); connection.close(); server.close();

public static void main(String[] args) { // Register service on port 1234 ServerSocket server = new ServerSocket(1234); // Wait and accept a connection Socket connection = server.accept(); // Get a communication stream associated with the socket OutputStream os = connection.getOutputStream(); DataOutputStream output = new DataOutputStream(os); // Send a string! output.writeUTF("Hi there"); // Close the connection output.close(); os.close(); connection.close(); server.close(); } Simple Server (one client)

Simple Client 1.Create a Socket Connection 2.Create Streams for Communication 3.Carry Out Communication 4.Close Communication

Simple Client 1.Create a Socket Connection SocketConnection connection = (SocketConnection)Connector.open("socket://gbcs10:123"); 2.Create Streams for Communication 3.Carry Out Communication 4.Close Communication

Simple Client 1.Create a Socket Connection SocketConnection connection = (SocketConnection)Connector.open("socket://gbcs10:5678"); 2.Create Streams for Communication InputStream is = connection.openInputStream(); DataInputStream input = new DataInputStream(is); 3.Carry Out Communication 4.Close Communication

Simple Client 1.Create a Socket Connection SocketConnection connection = (SocketConnection)Connector.open("socket://gbcs10:5678"); 2.Create Streams for Communication InputStream is = connection.openInputStream(); DataInputStream input = new DataInputStream(is); 3.Carry Out Communication String data = new String (input.readUTF()); 4.Close Communication

Simple Client 1.Create a Socket Connection SocketConnection connection = (SocketConnection)Connector.open("socket://gbcs10:5678"); 2.Create Streams for Communication InputStream is = connection.openInputStream(); DataInputStream input = new DataInputStream(is); 3.Carry Out Communication String data = new String (input.readUTF()); 4.Close Communication is.close(); input.close(); connection.close();

Simple Client try { SocketConnection connection = (SocketConnection) Connector.open("socket://gbcs10:1234"); InputStream is = connection.openInputStream(); DataInputStream input = new DataInputStream(is); String data = new String (input.readUTF()); is.close(); input.close(); connection.close(); } catch (...) { }

Lab Exercise Client-Server Communication