1 / 16

Introduction to Interprocess communication

Introduction to Interprocess communication. How do the objects within an application communicate?. Approaches you may have already used. Object A calls a method of Object B, supplying Object C (data) as method argument Object A and Object B both access Object C (a shared data object)

odelia
Télécharger la présentation

Introduction to Interprocess communication

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Interprocess communication SE-2811 Dr. Mark L. Hornick

  2. How do the objects within an application communicate? SE-2811 Dr. Mark L. Hornick

  3. Approaches you may have already used • Object A calls a method of Object B, supplying Object C (data) as method argument • Object A and Object B both access Object C (a shared data object) • Object A creates/modifies (“writes”) Object C • Object B “reads” Object C This approach can be used to exchange data between threads, by using wait/notify to synchronize the writing/reading of the data SE-2811 Dr. Mark L. Hornick

  4. Another way to exchange data • Object A writes to a file; Object B reads from the file This approach can also be used to exchange data between processes, since the physical file exists outside the life of a process • Actually, Object A writes to an output stream connected to a file, while Object B reads from an input streamalso connected to that file SE-2811 Dr. Mark L. Hornick

  5. A stream is a serial sequence of data Input Streams are used to read data from a source Output Streams are used to write data to a destination SE-2811 Dr. Mark L. Hornick

  6. A File is just a particular case of the source or destination of an I/O stream Under the hood, we are really writing to and reading data to the sectors and tracks of hardware device – a drive. The stream and File objects abstract the detail in an easier-to-use form. The java.io package contains many stream classes that abstract these operations differently: • DataXXputStream, ObjectXXputStream, PrintStream SE-2811 Dr. Mark L. Hornick

  7. What other computer hardware deals with sequential bits and bytes? SE-2811 Dr. Mark L. Hornick

  8. More generally, streams can be connected to a number of serial devices: • Files • Keyboards • Consoles • Serial ports • WAN ports • Memory SE-2811 Dr. Mark L. Hornick

  9. Piped Streams don’t use files at all A object can write to a piped output stream to send data directly to another object reading a piped input stream • The piped output stream must be connected to a piped input stream Essentially, the output pipe writes to a memory buffer (not a file) and the input pipe reads from that buffer • The output and input pipe can be accessed from separate threads SE-2811 Dr. Mark L. Hornick

  10. Demo SE-2811 Dr. Mark L. Hornick

  11. Limitation of Java piped I/O Some underlying OS’s support the concept of named pipes, which allows: • An output pipe to be written from within one process • An input pipe to be read from within a second process Java’s pipes are not named and do not support the concept of named pipes directly, so Java piped I/O is generally used for inter-thread data exchange SE-2811 Dr. Mark L. Hornick

  12. A socket is a higher-level abstraction of the end-point of a two-way communication link between a data source and a destination As with Files, streams are used to read from and write to sockets Each socket uses two streams • An input stream for reading data coming into the socket • An output stream for writing data to another socket SE-2811 Dr. Mark L. Hornick

  13. Data is sent from one socket to another Each socket can be implemented in a separate process • Allowing two processes to exchange data The two processes do not have to be running on the same computer • Allowing processes on separate computers, connected by a network, to exchange data SE-2811 Dr. Mark L. Hornick

  14. Every socket has a unique identifier A socket on one computer connects to a socket on a another computer by locating it by its identifier • URL – Uniform Resource Locator Some examples of a URL: • www.msoe.edu – a DNS name • 192.168.2.101 – an IP address • 127.0.0.1 – the self-address of every computer SE-2811 Dr. Mark L. Hornick

  15. A single computer has a single URL But can support many sockets • Each socket is assigned a port number • Port numbers can range from 0 – 65535 Some port numbers are reserved for sockets used in well-known applications • Web servers and browsers use port 80 for data exchange using the http protocol • FTP clients and servers use ports 20 and 21 for file data transfer and file transfer commands • The first 1024 ports are reserved for these well-known applications SE-2811 Dr. Mark L. Hornick

  16. Once an application locates a specific socket, it can access it’s streams and read and write to that socket • Demo SE-2811 Dr. Mark L. Hornick

More Related