Content area
When publishing files to a file-sharing service, you typically interact only with the servant program, which can access the service. The file-sharing service's servant is connected to Gnutella and is continuously responding to search queries from the network, eliminating the need for an intermediary search engine. The documents remain on the user's computer and are not transferred. Gnutella shares a document by copying the file to a shared directory and having the servant scan and index the file. Since the file-sharing system publishes and indexes documents, the user has much less work to do. Also, the user has the option to share files for a limited amount of time; simply removing the Gnutella servant from the network will end the session.
Like many Internet technologies, Gnutella benefits from a protocol specification that is available to the public. The protocol provides a compatibility point that allows Gnutella servants to communicate across operating systems and programming languages. As long as a Gnutella servant implements the protocol, it can participate in the file-sharing network.
This code constructs a NetworkConnection that supplies an IP address/host name and the port used by the Gnutella servant that is listening on the remote machine. Internally, the NetworkConnection attempts to open a socket to this machine; if that succeeds, the Gnutella protocol handshake is exchanged. The NetworkConnection treats this servant as a host cache and sends a PING to it.