Comunicação entre processos baseada em troca de mensagens através de sockets sobre IP Alcides Calsavara.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Network Programming and Java Sockets
Network Programming Chapter 11 Lecture 6. Networks.
Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Application Layer – Lecture.
2: Application Layer 1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
1 Creating a network app Write programs that  run on different end systems and  communicate over a network.  e.g., Web: Web server software communicates.
Prepared By E. Musa Alyaman1 User Datagram Protocol (UDP) Chapter 5.
2: Application Layer1 Data Communication and Networks Lecture 12 Java Sockets November 30, 2006.
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
1 Overview r Socket programming with TCP r Socket programming with UDP r Building a Web server.
Java Socket Support Presentation by: Lijun Yuan Course Number: cs616.
Internet and Intranet Protocols and Applications Lecture 4: Application Layer 3: Socket Programming February 8, 2005 Arthur Goldberg Computer Science Department.
Socket programming with UDP and TCP. Socket Programming with TCP Connection oriented – Handshaking procedure Reliable byte-stream.
1 School of Computing Science Simon Fraser University CMPT 771/471: Internet Architecture and Protocols Socket Programming Instructor: Dr. Mohamed Hefeeda.
© 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.
2: Application Layer1 Socket Programming. 2: Application Layer2 Socket-programming using TCP Socket: a door between application process and end- end-transport.
1 Network Layers Application Transport Network Data-Link Physical bits.
Protocols Rules for communicating between two entities (e.g., a client and a server) “A protocol definition specifies how distributed system elements interact.
2: Application Layer 1 Socket Programming Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross Addison-Wesley,
Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers.
2: Application Layer 1 Socket Programming TCP and UDP.
JAVA Socket Programming Source: by Joonbok Lee, KAIST, 2003.
2: Application Layer1 Chapter 2 Application Layer Computer Networking: A Top Down Approach Featuring the Internet, 2 nd edition. Jim Kurose, Keith Ross.
SOCKET PROGRAMMING. Client/Server Communication At a basic level, network-based systems consist of a server, client, and a media for communication as.
2: Application Layer1 Chapter 2: Application layer r 2.1 Principles of network applications r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail  SMTP,
2: Application Layer1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
CS 3830 Day 11 Introduction : Application Layer 2 Server-client vs. P2P: example Client upload rate = u, F/u = 1 hour, u s = 10u, d min ≥ u s.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
Chapter 2 Application Layer Computer Networking: A Top Down Approach, 5 th edition. Jim Kurose, Keith Ross Addison-Wesley, April A note on the use.
Winter 2002Suprakash Datta1 Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
-1- Georgia State UniversitySensorweb Research Laboratory CSC4220/6220 Computer Networks Dr. WenZhan Song Associate Professor, Computer Science.
Socket Programming Lee, Sooyong
Network Programming and Sockets CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison.
 TCP (Transport Control Protocol) is a connection-oriented protocol that provides a reliable flow of data between two computers.  TCP/IP Stack Application.
Socket Programming Tutorial. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
© Lethbridge/Laganière 2005 Chap. 3: Basing Development on Reusable Technology The Client-Server Architecture A distributed system is a system in.
Java Socket programming. Socket programming with TCP.
Application Network programming Using Java. Application Layer2-2 Socket programming socket: door between application process and end-end-transport protocol.
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
From Coulouris, Dollimore, Kindberg and Blair Distributed Systems: Concepts and Design Edition 5, © Addison-Wesley 2012 Slides for Chapter 4: Interprocess.
Slides for Chapter 4: Interprocess Communication From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 4, © Addison-Wesley.
2: Application Layer1 Chapter 2: Application layer r 2.1 Principles of network applications r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail  SMTP,
2: Application Layer1 Socket programming Socket API Explicitly created, used, released by apps Client/server paradigm Two types of transport service via.
1 CSCD 330 Network Programming Spring 2014 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 7 Application.
1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm r two types of.
TCP/IP Protocol Stack IP Device Drivers TCPUDP Application Sockets (Gate to network) TCP: –Establish connection –Maintain connection during the communication.
1 Netprog 2002 TCP/IP UDP/IP in Java Based on Java Network Programming and Distributed Computing.
1 COMP 431 Internet Services & Protocols Client/Server Computing & Socket Programming Jasleen Kaur February 2, 2016.
Java Programming II Java Network (I) Java Programming II.
1 CSCD 330 Network Programming Fall 2013 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 8a Application.
UDP User Datagram Protocol. About the UDP A commonly used transport protocol Does not guarantee either packet delivery or order The packets may travel.
Socket programming in C. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 11 Omar Meqdadi Department of Computer Science and Software Engineering University.
Application Network programming Using Java. Application Layer2-2 Socket programming socket: door between application process and end-end-transport protocol.
1 All rights reserved to Chun-Chuan Yang Upon completion you will be able to: The OSI Model and the TCP/IP Protocol Suite Understand the architecture of.
Network Programming Communication between processes Many approaches:
Socket Programming Ameera Almasoud
Socket Programming Socket Programming Overview
Socket programming with TCP
Chapter 2: outline 2.1 principles of network applications
Socket programming - Java
CSCD 330 Network Programming
Socket Programming.
CSCD 330 Network Programming
Socket Programming 2: Application Layer.
CPSC 441 UDP Socket Programming
Chapter 2: Application layer
Socket Programming with UDP
Based on Java Network Programming and Distributed Computing
Review Communication via paired sockets, one local and one remote
Presentation transcript:

Comunicação entre processos baseada em troca de mensagens através de sockets sobre IP Alcides Calsavara

Sockets Basic TCP/IP mechanism Three access facilities: –connection-oriented: Socket, ServerSocket –datagram-oriented: DatagramSocket MulticastSocket –raw IP data: SocketImpl

Connection-oriented sockets Built over TCP/IP Reliable services: no data losses in the network data ordering is insured Trade-off: slower than datagrams Data streams can be created Asymmetric behaviors client side Vs. server side

Connection: client actions 1. Open the communication socket import java.io.* ; // streams import java.net.* ; // sockets Socket clientSocket = new Socket (“ 80) ;

Connection: client actions 2. Get socket input/output streams: DataInputStream inbound = new DataInputStream ( clientSocket.getInputStream( ) ) ; DataOutputStream outbound = new DataOutputStream ( clientSocket.getOutputStream( ) ) ;

Connection: client actions 3. Use the input/output streams outbound.writeInt( 3 ); outbound.writeUTF( “Hello” ); int k = inbound.readInt( ); String s = inbound.readUTF() ;...

Connection: client actions 4. Close in/out streams inbound.close () ; outbound.close () ; 5. Close the socket clientSocket.close() ;

Connection: server actions 1. Create server-side socket: ServerSocket serverSocket = new ServerSocket (80, 5) ; 2. Wait for client connections: Socket clientSocket = serverSocket.accept () ;

Connection: server actions 3. Create client in/out streams: DataInputStream inbound = new DataInputStream ( clientSocket.getInputStream( ) ) ; DataOutputStream outbound = new DataOutputStream ( clientSocket.getOutputStream( ) ) ;

Connection: server actions 4. Dialog with the client: int k = inbound.readInt( ); String s = inbound.readUTF() ; outbound.writeInt( 3 ); outbound.writeUTF( “Hello” );

Connection: server actions 5. Close streams and client socket: inbound.close () ; outbound.close () ; clientSocket.close() ; 6. Close server-side socket: serverSocket.close() ;

Datagram sockets Based on UDP/IP unreliable service: messages can be lost messages ordering is not guaranteed but it’s much faster the TCP/IP Each message is a “datagram”: [sender, receiver, contents]

Datagram, sender side 1. Client socket creation: // sender socket doesn’t need // a special port number DatagramSocket clientSocket = new DatagramSocket () ;

Datagram, sender side 2. Build and send the datagram: InetAddress addr=InetAddress.getByName (“ ; String toSend = “That’s my question!” ; byte[] buffer = toSend.getBytes() ; // datagram to receiver’s port 4545 DatagramPacket question = new DatagramPacket (buffer, buffer.length, addr, 4545) ; clientSocket.send (question) ;

Datagram, sender side 3. Receive and open the answer: DatagramPacket answer = new DatagramPacket (new byte[512], 512); clientSocket.receive (answer) ; System.out.println (answer.getData() + “\n” + answer.getLength() + “\n” + answer.getAddress() + “\n” + answer.getPort() ) ;

Datagram, sender side 4. Close the client socket: clientSocket.close() ;

Datagram, receiver side 1. Create a server socket: // listens on port 4545 DatagramSocket serverSocket = new DatagramSocket (4545) ;

Datagram, receiver side 2. Receive a datagram: DatagramPacket question = new DatagramPacket (new byte[512], 512) ; serverSocket.receive (question) ;

Datagram, receiver side 3. Send the answer datagram: String toSend = “That’s the answer !” ; byte[] buffer = toSend.getBytes() ; DatagramPacket answer = new DatagramPacket (buffer, buffer.length, question.getAddress(), // sender info question.getPort() ) ; // sender info serverSocket.send (answer) ;

Datagram, receiver side 4. Close the server socket: serverSocket.close() ;