DOC PREVIEW
CMU ISM 95702 - Coulouris Interprocess Communication

This preview shows page 1-2-3-27-28-29 out of 29 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

OCT Chapter 4 Coulouris Interprocess CommunicationMiddleware layersSockets and portsUDP client sends a message to the server and gets a replyUDP server repeatedly receives a request and sends it back to the clientTCP client makes connection to server, sends request and receives replyTCP server makes a connection for each client and then echoes the client’s requestcontinuedExternal Data Representation and MarshallingSlide 10Slide 11Slide 12CORBA Common Data Representation (CDR) for constructed typesCORBA CDR messageCORBAJavaSlide 17Indication of Java serialized formRepresentation of a remote object referenceFigure 4.11 Request-reply communicationFigure 4.12 Operations of the request-reply protocolFailure model of request reply protocolFailure model – handling duplicatesFigure 4.13 Request-reply message structureRPC exchange protocols identified by Spector[1982]HTTP request messageHTTP SOAP messageTraditional HTTP reply messageHTTP Web Services SOAP reply messageOCT --OCTChapter 4 CoulourisInterprocess CommunicationOCT --Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 Middleware layersApplications, servicesMiddlewarelayersrequest-reply protocolmarshalling and external data representationUDP and TCPThischapterRMI and RPCOCT --Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 Sockets and portsmessageagreed portany portsocketsocketInternet address = 138.37.88.249Internet address = 138.37.94.248other portsclientserverOCT --Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 UDP client sends a message to the server and gets a replyimport java.net.*;import java.io.*;public class UDPClient{ public static void main(String args[]){ // args give message contents and server hostnameDatagramSocket aSocket = null; try {aSocket = new DatagramSocket(); byte [] m = args[0].getBytes();InetAddress aHost = InetAddress.getByName(args[1]);int serverPort = 6789; DatagramPacket request = new DatagramPacket(m, args[0].length(), aHost, serverPort);aSocket.send(request); byte[] buffer = new byte[1000];DatagramPacket reply = new DatagramPacket(buffer, buffer.length);aSocket.receive(reply);System.out.println("Reply: " + new String(reply.getData())); }catch (SocketException e){System.out.println("Socket: " + e.getMessage()); }catch (IOException e){System.out.println("IO: " + e.getMessage());}}finally {if(aSocket != null) aSocket.close();} } }OCT --Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 UDP server repeatedly receives a request and sends it back to the clientimport java.net.*;import java.io.*;public class UDPServer{public static void main(String args[]){ DatagramSocket aSocket = null; try{ aSocket = new DatagramSocket(6789);byte[] buffer = new byte[1000]; while(true){ DatagramPacket request = new DatagramPacket(buffer, buffer.length); aSocket.receive(request); DatagramPacket reply = new DatagramPacket(request.getData(), request.getLength(), request.getAddress(), request.getPort()); aSocket.send(reply);} }catch (SocketException e){System.out.println("Socket: " + e.getMessage()); }catch (IOException e) {System.out.println("IO: " + e.getMessage());}}finally {if(aSocket != null) aSocket.close();} }}OCT --Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 TCP client makes connection to server, sends request and receives replyimport java.net.*;import java.io.*;public class TCPClient {public static void main (String args[]) {// arguments supply message and hostname of destinationSocket s = null; try{ int serverPort = 7896; s = new Socket(args[1], serverPort); DataInputStream in = new DataInputStream( s.getInputStream());DataOutputStream out =new DataOutputStream( s.getOutputStream());out.writeUTF(args[0]); // UTF is a string encoding see Sn 4.3String data = in.readUTF(); System.out.println("Received: "+ data) ; }catch (UnknownHostException e){System.out.println("Sock:"+e.getMessage()); }catch (EOFException e){System.out.println("EOF:"+e.getMessage()); }catch (IOException e){System.out.println("IO:"+e.getMessage());}}finally {if(s!=null) try {s.close();}catch (IOException e){System.out.println("close:"+e.getMessage());}} }}OCT --Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 TCP server makes a connection for each client and then echoes the client’s requestimport java.net.*;import java.io.*;public class TCPServer { public static void main (String args[]) {try{int serverPort = 7896; ServerSocket listenSocket = new ServerSocket(serverPort);while(true) {Socket clientSocket = listenSocket.accept();Connection c = new Connection(clientSocket);}} catch(IOException e) {System.out.println("Listen :"+e.getMessage());} }}// this figure continues on the next slideOCT --Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 continuedclass Connection extends Thread {DataInputStream in;DataOutputStream out;Socket clientSocket;public Connection (Socket aClientSocket) { try {clientSocket = aClientSocket;in = new DataInputStream( clientSocket.getInputStream());out =new DataOutputStream( clientSocket.getOutputStream());this.start(); } catch(IOException e) {System.out.println("Connection:"+e.getMessage());}}public void run(){ try { // an echo serverString data = in.readUTF(); out.writeUTF(data); } catch(EOFException e) {System.out.println("EOF:"+e.getMessage()); } catch(IOException e) {System.out.println("IO:"+e.getMessage());} } finally{ try {clientSocket.close();}catch (IOException e){/*close failed*/}}}}OCT --Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000 External Data Representation and MarshallingMessages consist of sequences of bytesInteroperability ProblemsBig-endian, little-endian byte ordering Floating point


View Full Document

CMU ISM 95702 - Coulouris Interprocess Communication

Documents in this Course
Homework

Homework

12 pages

Lecture

Lecture

25 pages

Lecture

Lecture

21 pages

Lecture

Lecture

24 pages

Exam

Exam

11 pages

Homework

Homework

16 pages

Homework

Homework

38 pages

lecture

lecture

38 pages

review

review

7 pages

lecture

lecture

18 pages

review

review

8 pages

Chapter2

Chapter2

32 pages

Lecture 4

Lecture 4

47 pages

Lecture

Lecture

22 pages

Naming

Naming

26 pages

lecture

lecture

34 pages

lecture

lecture

42 pages

lecture

lecture

112 pages

Lecture

Lecture

33 pages

Axis

Axis

43 pages

lecture

lecture

32 pages

review

review

17 pages

Lecture

Lecture

53 pages

Lecture

Lecture

80 pages

Lab

Lab

14 pages

Load more
Download Coulouris Interprocess Communication
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Coulouris Interprocess Communication and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Coulouris Interprocess Communication 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?