| CONTENTS |PREV |NEXT | Java Remote Method Invocation |
In
The input and outputstreams used by RMI are paired. EachOut stream has acorrespondingIn stream. AnOut stream in thegrammar maps to the output stream of a socket (from theclient's perspective). AnIn stream (in the grammar)is paired with the corresponding socket's input stream. Sinceoutput and input streams are paired, the only header informationneeded on an input stream is an acknowledgment as to whether theprotocol is understood; other header information (such as the magicnumber and version number) can be implied by the context of streampairing.
TheMessagesare wrapped within a particular protocol as specified byProtocol. For theSingleOpProtocol, there mayonly be oneMessage after theHeader, and thereis no additional data that theMessage is wrapped in. TheSingleOpProtocol is used for invocation embedded in HTTPrequests, where interaction beyond a single request and response isnot possible.
For theStreamProtocol and theMultiplexProtocol, theserver must respond with a a byte0x4e acknowledgingsupport for the protocol, and anEndpointIdentifier thatcontains the host name and port number that the server can see isbeing used by the client. The client can use this information todetermine its host name if it is otherwise unable to do that forsecurity reasons. The client must then respond with anotherEndpointIdentifier that contains the client's defaultendpoint for accepting connections. This can be used by a server intheMultiplexProtocol case to identify the client.
For theStreamProtocol, after this endpoint negotiation, theMessages are sent over the output stream without anyadditional wrapping of the data. For theMultiplexProtocol, the socket connection is used as theconcrete connection for a multiplexed connection, as described inSection 10.6, "RMI'sMultiplexing Protocol." Virtual connections initiated overthis multiplexed connection consist of a series ofMessages as described below.
There are three types ofoutput messages:Call,Ping andDgcAck.ACall encodes a method invocation. APing is atransport-level message for testing liveness of a remote virtualmachine. ADGCAck is an acknowledgment directed to aserver's distributed garbage collector that indicates thatremote objects in a return value from a server have been receivedby the client.