title: Publishing a stream using librtmp in C/C++
body: <p>How to publish a stream using librtmp library? 
  I read the librtmp man page and for publishing , RTMP_Write() is used.</p>
  
  <p>I am doing like this.</p>
  
  <pre><code>//Code
  //Init RTMP code
  RTMP *r;
  char uri[]="rtmp://localhost:1935/live/desktop";
  r= RTMP_Alloc();
  RTMP_Init(r);
  RTMP_SetupURL(r, (char*)uri);
  RTMP_EnableWrite(r);
  RTMP_Connect(r, NULL);
  RTMP_ConnectStream(r,0);
  </code></pre>
  
  <p>Then to respond to ping/other messages from server, I am using a thread to respond like following:</p>
  
  <pre><code>//Thread
  While (ThreadIsRunning &amp;&amp; RTMP_IsConnected(r) &amp;&amp; RTMP_ReadPacket(r, &amp;packet))
  {
     if (RTMPPacket_IsReady(&amp;packet))
     {
   if (!packet.m_nBodySize)
           continue;
      RTMP_ClientPacket(r, &amp;packet); //This takes care of handling ping/other messages
      RTMPPacket_Free(&amp;packet);
     }
  }
  </code></pre>
  
  <p>After this I am stuck at how to use RTMP_Write() to publish a file to Wowza media server?</p>