<br>Hi.<br><br>I&#39;m having trouble getting a sample app to actually use my stun server... I can tell on the server side that my server isn&#39;t getting hit... But I am setting the ip and port here... any ideas?<br><br>
    td<br><br><br><span style="font-family: courier new,monospace;">#include &lt;glib.h&gt;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">#include &lt;nice/nice.h&gt;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">GMainContext* mainContext = NULL;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">GMainLoop* mainLoop = NULL;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">NiceAgent* niceAgent = NULL;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">NiceAddress baseAddress;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">guint streamId = 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">GSList* localCandidates = NULL;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">static void cb_candidate_gathering_done( NiceAgent *agent,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                                         guint stream_id,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                                         gpointer data )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    printf(&quot;cb_candidate_gathering_done()\n&quot;);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    fflush(stdout);</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    // Get the discovered local candidates...</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    GSList* localCandidates = nice_agent_get_local_candidates( niceAgent, streamId, 1 );</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    GSList* current = localCandidates;</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    while( current )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        NiceCandidate* candidate = (NiceCandidate*)current-&gt;data;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        if( candidate )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            switch( candidate-&gt;type )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">            {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            case NICE_CANDIDATE_TYPE_HOST:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                printf(&quot;NICE_CANDIDATE_TYPE_HOST\n&quot;);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                fflush(stdout);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                break;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            case NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                printf(&quot;NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE\n&quot;);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                fflush(stdout);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                break;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            case NICE_CANDIDATE_TYPE_PEER_REFLEXIVE:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                printf(&quot;NICE_CANDIDATE_TYPE_PEER_REFLEXIVE\n&quot;);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                fflush(stdout);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                break;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            case NICE_CANDIDATE_TYPE_RELAYED:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                printf(&quot;NICE_CANDIDATE_TYPE_RELAYED\n&quot;);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                fflush(stdout);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                break;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            default:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                printf(&quot;UNKNOWN CANDIDATE!\n&quot;);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                fflush(stdout);                </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                break;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            };            </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        }</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        current = current-&gt;next;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    }</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">[ ... removed empty callback functions ... ]</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">int main( int argc, char* argv[] )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    g_type_init();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    g_thread_init( NULL );</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    // Create a glib application context and mainloop object...</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    //</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    mainContext = g_main_context_new();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    mainLoop = g_main_loop_new( mainContext, FALSE );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    // Create our main nice agent...</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    //</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    niceAgent = nice_agent_new( mainContext, NICE_COMPATIBILITY_RFC5245 );</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    // Specify which local interface to use...</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    //</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    nice_address_set_from_string( &amp;baseAddress, &quot;127.0.0.1&quot; );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    nice_agent_add_local_address( niceAgent, &amp;baseAddress );</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    // Connect callback functions...</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    //</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    g_signal_connect( G_OBJECT( niceAgent ),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                      &quot;candidate-gathering-done&quot;,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                      G_CALLBACK( cb_candidate_gathering_done ),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                      GUINT_TO_POINTER(1) );</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    [ ... removed some extra callback registration ... ]</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    // Configure Stun server information...</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    //</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    g_object_set( G_OBJECT( niceAgent ), &quot;stun-server&quot;, &quot;97.74.202.52&quot;, NULL );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    g_object_set( G_OBJECT( niceAgent ), &quot;stun-server-port&quot;, 3478, NULL );</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    // Create a &quot;stream&quot; and attach it to our agent...</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    //</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    streamId = nice_agent_add_stream( niceAgent, 1 );</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    g_object_set_data( G_OBJECT( niceAgent ), &quot;id&quot;, GUINT_TO_POINTER(streamId) );</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    // Begin the local candidate gathering process...</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    //</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    nice_agent_gather_candidates( niceAgent, streamId );</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    // attach recv callback handler...</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    //</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    nice_agent_attach_recv( niceAgent,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                            streamId,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                            1,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                            mainContext,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                            cb_nice_recv,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                            GUINT_TO_POINTER(1) );</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    // Finally, start the glib MainLoop so we can start receiving events...</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    //</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    g_main_loop_run( mainLoop );</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    while( g_main_loop_is_running( mainLoop ) );</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    g_main_loop_unref( mainLoop );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    g_object_unref( niceAgent );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    return 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;">
<br>