title: How to create an Icecast client like Butt
body: <p>I need to create an Icecast client in C#. The main objective of this it's to send the incoming audio from two audio devices to be broadcast via Icecast.</p>
  
  <p>When I was searching for some solution already made, I found Butt which was exactly what I needed but I also needed to send to the Icecast two audio devices individually.</p>
  
  <p>I'm already getting the audio input from the two microphones and save them in a folder (one audio file for each microphone).
  Now I need to broadcast individually the two microphone to Icecast.</p>
  
  <p>All this is because I need to broadcast the two microphones like a radio station (one station for each microphone).</p>
  
  <p>The main solution it's something like this:</p>
  
  <ul>
  <li>Microphone 1 => Broadcast to Icecast like Source Micro1 => Save audio
  like micro1.mp3 format (working).</li>
  <li>Microphone 2 => Broadcast to
  Icecast like Source Micro2 => Save audio like micro2.mp3 format
  (working).</li>
  </ul>
  
  <p>I need to know how can I broadcast to icecast, i'm using NAudio library to get the audio input and save it.</p>
  
  <p>EDIT:
  I'm communicating with Icecast from C#, this is my code:</p>
  
  <pre><code>public static void commIcecast(string url)
      {
          WebClient client = new WebClient();
  
          client.Headers.Add("content-type", "audio/mpeg");
          client.Headers.Add("Authorization", "Basic c291cmNlOmhhY2ttZQ==");
          client.Headers.Add("ice-name", "This is my server name");
          client.Headers.Add("ice-url", "http://www.google.com");
          client.Headers.Add("ice-genre", "Rock");
          client.Headers.Add("ice-description", "This is my server description");
          client.Headers.Add("ice-audio-info", "ice-samplerate=44100;ice-bitrate=128;ice-channels=2");
  
          Stream data = client.OpenRead(url);
          StreamReader reader = new StreamReader(data);
          string s = reader.ReadToEnd();
          Console.WriteLine(s);
          data.Close();
          reader.Close();
      }
  </code></pre>
  
  <p>But i'm just reciving this answer from the Icecast server:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Icecast Streaming Media Server&lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" href="style.css"&gt;
  &lt;/head&gt;
  &lt;body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"&gt;
  &lt;h2&gt;Icecast2 Status&lt;/h2&gt;
  &lt;br&gt;&lt;div class="roundcont"&gt;
  &lt;div class="roundtop"&gt;&lt;img src="/corner_topleft.jpg" class="corner" style="display: none"&gt;&lt;/div&gt;
  &lt;table border="0" width="100%" id="table1" cellspacing="0" cellpadding="4"&gt;&lt;tr&gt;&lt;td bgcolor="#656565"&gt;
  &lt;a class="nav" href="admin/"&gt;Administration&lt;/a&gt;&lt;a class="nav" href="status.xsl"&gt;Server Status&lt;/a&gt;&lt;a class="nav" href="server_version.xsl"&gt;Version&lt;/a&gt;
  &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
  &lt;div class="roundbottom"&gt;&lt;img src="/corner_bottomleft.jpg" class="corner" style="display: none"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;br&gt;&lt;br&gt;&amp;nbsp;
  
  
  &lt;div class="poster"&gt;Support icecast development at &lt;a class="nav" target="_blank" href="http://www.icecast.org"&gt;www.icecast.org&lt;/a&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I've tried to send the "SOURCE /mp3test ICE/1.0" but the Headers.Add method don't allow me to do that.</p>
  
  <p>EDIT: I'm sending this via tcp to Icecast, but i can't recibe the response, i just need to know if this way to send it , if it's right now i'll have to move the post to tcp issues.
  I'm not reciving any response of the Icecast server using this method of sending.</p>
  
  <pre><code>            System.Net.IPAddress address = System.Net.IPAddress.Parse(url);
  
              socketServer = new TcpClient(url, port);
              NetworkStream networkStream = socketServer.GetStream();
  
              data = Encoding.ASCII.GetBytes("SOURCE /csharp ICE/1.0");
              networkStream.Write(data, 0, data.Length);
  
              data = Encoding.ASCII.GetBytes("content-type: audio/mpeg");
              networkStream.Write(data, 0, data.Length);
  
              data = Encoding.ASCII.GetBytes("Authorization: Basic c291cmNlOmhhY2ttZQ==");
              networkStream.Write(data, 0, data.Length);
  
              data = Encoding.ASCII.GetBytes("ice-name: lala");
              networkStream.Write(data, 0, data.Length);
  
              data = Encoding.ASCII.GetBytes("ice-url: localhost");
              networkStream.Write(data, 0, data.Length);
  
              data = Encoding.ASCII.GetBytes("ice-genre: Rock");
              networkStream.Write(data, 0, data.Length);
  
              data = Encoding.ASCII.GetBytes("ice-bitrate: 128");
              networkStream.Write(data, 0, data.Length);
  
              data = Encoding.ASCII.GetBytes("ice-private: 0");
              networkStream.Write(data, 0, data.Length);
  
              data = Encoding.ASCII.GetBytes("ice-public: 1");
              networkStream.Write(data, 0, data.Length);
  
              data = Encoding.ASCII.GetBytes("ice-description: This is my server description");
              networkStream.Write(data, 0, data.Length);
  
              data = Encoding.ASCII.GetBytes("ice-audio-info: ice-samplerate=44100;ice-bitrate=128;ice-channels=2");
              networkStream.Write(data, 0, data.Length);
  
              StreamReader reader = new StreamReader(networkStream);
              Console.WriteLine(reader.ReadToEnd());
  </code></pre>
  
  <p>With this i can connect to the Icecast server, at least the number of clients connected increase in the global statistics in Icecast, but then the connection it's lost and i can't get any response.</p>