Interprocess Communication: Methods and Protocols
Interprocess Communication Essentials
Interprocess communication involves sending a message between a socket in one process and a socket in another.
Communication Forms
- In synchronous communication, sending and receiving processes synchronize with each message.
- In asynchronous communication, the send operation is non-blocking, and the receive operation can have varied behavior.
Message Destination
Internet protocols send messages to (Internet address, local port) pairs. Processes can use multiple ports to receive messages but cannot share ports.
Reliability
A communication channel is considered reliable if messages are guaranteed to be delivered despite a reasonable number of packet losses.
Message Ordering
Some applications require that messages be delivered in sender order, meaning the order in which they were transmitted.
Sockets
Processes use sockets bound to an Internet address and a local port for communication.
UDP Datagram Communication
UDP involves sending discrete packets of data. Sockets can be blocking or non-blocking.
Blocking Behavior
Sockets typically offer non-blocking sends and blocking receives for datagram communication.
Timeouts
A receive operation that blocks indefinitely is useful for servers awaiting client requests. Timeouts can be implemented for specific scenarios.
Receiving Messages
The receive method retrieves a message without specifying an origin.
Failure Model
A failure model defines reliable communication based on integrity and validity.
Omission Failures
Messages might be dropped due to checksum errors or lack of buffer space.
Ordering Issues
Messages can sometimes arrive out of order.
TCP Stream Communication
API to the TCP Protocol
Originating from BSD 4.x UNIX, the TCP API offers an abstraction of a byte stream for data exchange.
API for Stream Communication
When establishing a connection, one process acts as a server and the other as a client.
Message Sizes
Applications can determine the amount of data written to or read from a stream.
Handling Lost Messages
TCP uses acknowledgments to ensure delivery. If an acknowledgment is not received, the sender retransmits the data.
Flow Control
TCP attempts to match the speeds of processes reading from and writing to a stream, preventing the sender from overwhelming the receiver.
Message Duplication and Ordering
Message identifiers in IP packets enable the recipient to detect and discard duplicates and reorder messages.
Message Destinations
Processes establish a connection before communicating over a stream. Once connected, they can read and write data.
Failure Model
TCP uses checksums to detect and reject corrupted data, ensuring the integrity of communication.
Data Representation and Marshalling
Marshalling and Unmarshalling
This is the process of assembling or disassembling data items into a suitable form for transmission.
XML
Extensible Markup Language (XML) is a textual format for representing structured data, initially intended for self-describing documents.
CORBA’s Common Data Representation
CORBA defines an external representation for structured and primitive data types.
Java’s Object Serialization
Java serialization flattens an object or a tree of objects into a serialized form for storage or transmission.
XML in Detail
XML vs. HTML
HTML defines the appearance of web pages, while XML is used for writing structured documents for the Web.
XML Data Structure
XML data items are tagged with markup strings that describe the data’s logical structure and attributes.
XML in Web Services
XML enables clients to communicate with web services and define their interfaces and properties.
Attributes
A start tag can include attribute name-value pairs, such as id=”123456789″.
Naming Conventions
XML tag and attribute names generally start with a letter, an underscore, or a colon.
Binary Data
All information in XML elements must be expressed as character data.
XML Namespaces
An XML namespace is a set of names for element types and attributes, referenced by a URL.
xmlns Attribute
The xmlns attribute, with a URL value, refers to the file containing namespace definitions.
XML Schema
An XML schema defines the elements, attributes, nesting, and order of elements in a document.
Request-Replay Protocol
This protocol uses doOperation, getRequest, and sendReply primitives for communication.
Message Identifiers
Each message must have a unique identifier for effective management.
Remote Procedure Call (RPC)
RPC allows calling procedures or functions on a remote computer.
RPC vs. Web
RPC is an older technology that provides a mechanism for defining interfaces callable across a network.
XML-RPC
XML-RPC enables programs to make function or procedure calls over a network using HTTP and XML.
XML-RPC Requests
These are a combination of XML content and HTTP headers, specifying parameters and target procedure information.
XML-RPC Responses
An XML-RPC response can contain only one parameter, which may be an array or a struct, allowing complex data to be returned.