Peer to Peer (P2P) systems are typically decentralized, distributed and anonymous systems. Some examples of P2P systems are Napster, KaZaA, SETI@HOME, Gnutella and MojoNation. One common protocol for file-sharing P2P applications is Gnutella The Gnutella protocol requires peers to broadcast messages to their neighbors when they search files. The message passing generates a lot of traffic in the network, which degrades the quality of service. We propose the new method to optimize the speed of search and to improve the quality of service in a Gnutella based peer-to-peer environment with using semantic routing and priority of nodes. Once peers generate their “friends lists”, they use these lists to route queries in the network.In our approch peers can show interest in different categories This helps to reduce the search time and to decrease the network traffic by minimizing the number of messages circulating in the system as compared to standard Gnutella.