Message passing between processes and across networks offers a powerful method to integrate and coordinate various music programs, facilitating software reuse, modularity, and parallel processing. Networking can integrate components that use different languages and hardware. In this article we describe O2, a flexible protocol for communication ranging from the thread level up to the level of global networks. Messages in O2 are similar to those of Open Sound Control, but O2 offers many additional features, including discovery, clock synchronization, a reliable message delivery option, and routing based on services rather than specific network addresses. A bridge mechanism extends the reach of O2 to web browsers, shared memory threads, and small microcontrollers. The design, implementation, and applications of O2 are described.