In this paper, we propose DINPeer middleware to overcome limitations in current peer-to-peer (P2P) overlay systems. DINPeer exploits a spiral-ring method to discover an inner ring with relative largest bandwidth to form a DINloop (Data-In-Network loop). DINPeer further integrates DINloop with P2P overlay network via node state and routing algorithm. The key features of DINPeer include using DINloop to replace a multicast rendezvous point and turning DINloop into a cache to achieve application data persistency. Simulations show that DINPeer is able to optimize P2P communication in a number of ways, such as when the size of the DINloop is capped within a limit, it can achieve a better performance than native IP multicast and P2P overlay multicast systems.