Mastering JXTA Building Java Peer-to-Peer Applications Joseph D. Gradecki Wiley Publishing, Inc. Publisher: Robert Ipsen Editor: Robert M. Elliott Managing Editor: John Atkins Book Packaging: Ryan Publishing Group, Inc. Copyeditor: Elizabeth Welch Proofreader: Nancy Sixsmith Compositor: Gina Rexrode Technical Editor: Stan Ng Designations used by companies to distinguish their products are often claimed as trademarks. In all instances where Wiley Publishing, Inc., is aware of a claim, the product names appear in initial capital or ALL CAPITAL LETTERS. Readers, however, should contact the appropriate companies for more complete information regarding trademarks and registration. This book is printed on acid-free paper. ∞ Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4470. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspointe Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 5724447, email:
[email protected] Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages. For general information on our other products and services please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Cataloging-in-Publication Data: ISBN: 0-471-25084-8 Printed in the United States of America 10 9 8 7 6 5 4 3 2 1 Contents Chapter 8 Peer Information Protocol An Overview of the PIP PIP Query Messages PIP Response Messages Java Binding of the PIP Requesting Peer Information Building a Listener Viewing the Information Returned Summary Chapter 9 Peer Endpoint Protocol An Overview of the Peer Endpoint Protocol Endpoint Service Sending a Message Endpoint Protocols Java Binding of the Peer Endpoint Protocol Summary Chapter 10 Pipe Binding Protocol Overview of the Pipe Binding Protocol Pipe Advertisements Pipe Binding Query Messages Java Binding Creating a Pipe Receiving Information Building the Pipe Advertising the Pipe Discovering an Input Pipe Summary Chapter 11 Rendezvous Protocol Rendezvous Advertisements Message Propagation The Java Binding Dynamic Rendezvous Service Implementation Finding Rendezvous Peers Dyn