Free Programming Books
Free download ebooks on computer and programming

Free Ebook "Peer-to-Peer with VB .NET" Sample Chapter

Peer to Peer with VB.NET
Free downloads Chapter 4: Building a Simple Messenger
Download chapter

Peer-to-peer proponents claim that their technology holds the keys to building virtual supercomputers, sharing vast pools of knowledge, and creating self-sufficient communities on the Internet. Peer-to-Peer with VB .NET explores how these design ideas can be integrated into existing .NET applications.

This book is an honest assessment of P2P and .NET. It doesn't just explain how to create P2P applications-it examines the tradeoffs that professional developers will encounter with .NET and P2P. It also considers several different approaches (Remoting, .NET networking, etc.) rather than adopting one fixed technology, and includes detailed examples of several popular P2P application types (messenger, file sharer, and distributed task manager).

< < prev next > >

Building a Simple Messenger

THE LAST CHAPTER CONDUCTED a whirlwind tour of Remoting, .NET's object-based model for communication between applications and across a network. Remoting is a surprisingly flexible technology. By default, it's tailored for traditional enterprise computing, in which all the work is performed by a central group of powerful server computers. But with a little more effort, you can use Remoting as the basis for a peer-to-peer system that uses brokered communication. In this chapter, we'll explore one such example with an instant-messaging application that relies on a central coordinator. Along the way, you'll learn the advantages and drawbacks involved with using Remoting in a peer-to-peer project.

Though Remoting is fairly easy to use, there can be a fair bit of subtlety involved in using it correctly. In the example presented in this chapter, it's easy to ignore threading and concurrency problems, scalability considerations, and security. These details are explored in more detail in the next chapter. In this chapter, however, we'll concentrate on creating a basic, reliable framework for a messaging application based on Remoting.

Because the code is quite lengthy, it won't be presented in this chapter all at once. Instead, it's broken down and dissected in detail throughout the chapter. But before we consider a single line of code, we need to plan the overall architecture of the system, which we'll call Talk .NET.

Envisioning Talk .NET

Every Internet user is familiar with the basic model for an instant-messaging application. Users log on to some sort of central authority, retrieve a list that indicates who else is currently online, and exchange simple text messages. Some messaging platforms include additional enhancements, such as file-transfer features and group conversations that can include more than two parties.

All current-day instant-messaging applications rely on some sort of central component that stores a list of who is currently online as well as the information needed to contact them. Depending on the way the system is set up, peers may retrieve this information and contact a chosen user directly, or they may route all activity through the central coordinator. This chapter will consider both alternatives. We'll use the central coordinator approach first.