O'Reilly logo

JXTA in a Nutshell by Li Gong, Bernard Traversat, Scott Oaks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. The Pipe API

In this chapter, we’ll expand on our restaurant auction example from Chapter 4 to show how the RestoPeer and HungryPeer communicate with each other once they have each discovered and joined the RestoNet peergroup. From a functional point of view, this communication is the basis for what the distributed application does; communication between the peers enables the RestoPeer to offer services and the Hungry Peer to place bids on those services.

From a programming point of view, this communication is possible due to the Java API binding that JXTA provides for pipes. Pipes are the fundamental construct of JXTA that allow peers to communicate with each other; a peer that wants to offer a service creates and advertises a pipe to the JXTA peergroup. A peer that wants to use a service discovers pipe advertisements in a peergroup and makes a connection to the service via the pipe.

Once again, we’ll show only the Java language binding for JXTA pipes in this chapter. Because JXTA defines the protocol by which pipes are advertised and used, any JXTA peer can communicate with any other JXTA peer over the pipe; the two peers do not need to be programmed in the same language.

Creating Pipes

We’ll illustrate the use of pipes by modifying our previous auctioning example; we will add a set of pipes to allow HungryPeers and RestoPeers to communicate within the RestoNet peergroup. Since pipes are unidirectional, we need two pipes for a HungryPeer and RestoPeer to exchange ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required