title: How to transfer a list of buffers over a network
body: <p>I have a Java network application running two threads, one for capturing, encoding, and sending audio and one for receiving, decoding, and playing audio. The method I am using to encode the audio returns a <code>List&lt;ByteBuffer&gt;</code>. The decode method I want to use takes a <code>List&lt;ByteBuffer&gt;</code> as an argument, so I need to be able to reconstruct the list after sending the data across the network.</p>
  
  <p>The problem that I am having is that I can't figure out how to properly send all of the data across the network without it becoming corrupted. I believe I'm limited by my knowledge of network programming so I'm reaching out for help. I've experimented with a few different approaches (DatagramSockets/Packets, streams, SocketChannels, etc) but I haven't been able to successfully achieve my goal. There are no requirements on what network transmit protocol I need to use so any setup is fine. How can I send my list of buffers over the network so that I can reconstruct it in the receiving thread?</p>