<br>Hi,<br><br>Thanks for the tips. <br><br>Here are some references of Sockets i found in the code.<br>as i am planning to add tcp support to SIP channel i need to know which sockets are used , why they are used and what are the types (tcp/udp) ?
<br><br><span style="font-style: italic; font-weight: bold;"><font size="4">For ast_socket :</font><br><span style="font-style: italic;"><span style="font-weight: bold;">in the function </span></span><span style="font-style: italic;">
</span></span><span style="font-family: monospace; font-weight: bold;">ast_makesocket()</span><span style="font-weight: bold; font-style: italic;"><br></span><pre class="fragment">00893    <span class="keyword">struct </span>
sockaddr_un sunaddr;<br><a name="l00894"></a>00894    <span class="keywordtype">int</span> res;<br><a name="l00895"></a>00895    <span class="keywordtype">int</span> x;<br><a name="l00896"></a>00896    uid_t uid = -1;<br>
<a name="l00897"></a>00897    gid_t gid = -1;<br><a name="l00898"></a>00898 <br><a name="l00899"></a>00899    <span class="keywordflow">for</span> (x = 0; x &lt; <a class="code" href="http://asterisk.org/doxygen/asterisk_8c.html#a2">
AST_MAX_CONNECTS</a>; x++) <br><a name="l00900"></a>00900       <a class="code" href="http://asterisk.org/doxygen/asterisk_8c.html#a24">consoles</a>[x].<a class="code" href="http://asterisk.org/doxygen/structconsole.html#o0">
fd</a> = -1;<br><a name="l00901"></a>00901    unlink(<a class="code" href="http://asterisk.org/doxygen/asterisk_8c.html#a38">ast_config_AST_SOCKET</a>);<br><br><a name="l00902"></a>-&gt; 00902    <a style="font-weight: bold;" class="code" href="http://asterisk.org/doxygen/asterisk_8c.html#a16">
ast_socket</a><span style="font-weight: bold;"> = socket(</span><a style="font-weight: bold;" class="code" href="http://asterisk.org/doxygen/asterisk_8c.html#a1">PF_LOCAL</a><span style="font-weight: bold;">, SOCK_STREAM, 0);
<br><br></span><a name="l00903"></a>00903    <span class="keywordflow">if</span> (<a class="code" href="http://asterisk.org/doxygen/asterisk_8c.html#a16">ast_socket</a> &lt; 0) {<br><a name="l00904"></a>00904       <a class="code" href="http://asterisk.org/doxygen/logger_8c.html#a45">
ast_log</a>(<a class="code" href="http://asterisk.org/doxygen/logger_8h.html#a15">LOG_WARNING</a>, <span class="stringliteral">&quot;Unable to create control socket: %s\n&quot;</span>, strerror(errno));<br><a name="l00905">
</a>00905       <span class="keywordflow">return</span> -1;<br><a name="l00906"></a>00906    }     <br><a name="l00907"></a>00907    memset(&amp;sunaddr, 0, <span class="keyword">sizeof</span>(sunaddr));<br><a name="l00908">
</a>00908    sunaddr.sun_family = <a class="code" href="http://asterisk.org/doxygen/asterisk_8c.html#a0">AF_LOCAL</a>;<br><a name="l00909"></a>00909    ast_copy_string(sunaddr.sun_path, <a class="code" href="http://asterisk.org/doxygen/asterisk_8c.html#a38">
ast_config_AST_SOCKET</a>, <span class="keyword">sizeof</span>(sunaddr.sun_path));<br><br><a name="l00910"></a><span style="font-weight: bold;"><span style="font-weight: bold;">-&gt; </span>00910    res = bind(</span><a style="font-weight: bold;" class="code" href="http://asterisk.org/doxygen/asterisk_8c.html#a16">
ast_socket</a><span style="font-weight: bold;">, (</span><span style="font-weight: bold;" class="keyword">struct</span><span style="font-weight: bold;"> sockaddr *)&amp;sunaddr, </span><span style="font-weight: bold;" class="keyword">
sizeof</span><span style="font-weight: bold;">(sunaddr));<br><span style="font-weight: bold;"><br><br></span><font size="4"><span style="font-style: italic;">For sipsock:<br></span></font></span><font style="font-weight: bold;" size="4">
<span style="font-style: italic;"><font size="2"><span style="font-style: italic;">in function </span></font></span></font><font style="font-weight: bold;" size="2"><span class="keyword">static</span> <span class="keywordtype">
int</span> <a class="code" href="http://asterisk.org/doxygen/chan__h323_8c.html#a115">reload_config</a>(<span class="keyword">enum</span> <a class="code" href="http://asterisk.org/doxygen/channel_8h.html#a175">channelreloadreason
</a></font><font style="font-weight: bold;" size="2"> reason)</font><span style="font-weight: bold;"><font size="4"><span style="font-style: italic;"><span style="font-style: italic;"><span style="font-weight: bold;"></span>
</span><br></span></font></span> <span class="keywordflow">if</span> (<a class="code" href="http://asterisk.org/doxygen/chan__sip_8c.html#a254">sipsock</a> &lt; 0) {<br><a name="l15831"></a>15831       <a class="code" href="http://asterisk.org/doxygen/chan__sip_8c.html#a254">
sipsock</a> = socket(AF_INET, SOCK_DGRAM, 0);<br><a name="l15832"></a>15832       <span class="keywordflow">if</span> (<a class="code" href="http://asterisk.org/doxygen/chan__sip_8c.html#a254">sipsock</a> &lt; 0) {<br><a name="l15833">
</a>15833          <a class="code" href="http://asterisk.org/doxygen/logger_8c.html#a45">ast_log</a>(<a class="code" href="http://asterisk.org/doxygen/logger_8h.html#a15">LOG_WARNING</a>, <span class="stringliteral">&quot;Unable to create SIP socket: %s\n&quot;
</span>, strerror(errno));<br><a name="l15834"></a>15834       } <span class="keywordflow">else</span> {<br><a name="l15835"></a><br></pre>I don't know why are these separate sockets and 1 tcp and other udp?<br><br>Thanks in advance,
<br><br>Sameer<br><br><br>