[asterisk-dev] SOCKET
Sameer Tamsekar
stamsekar at gmail.com
Mon Jul 10 01:22:43 MST 2006
Hi,
Thanks for the tips.
Here are some references of Sockets i found in the code.
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) ?
For ast_socket :
in the function ast_makesocket()
00893 struct sockaddr_un sunaddr;
00894 int res;
00895 int x;
00896 uid_t uid = -1;
00897 gid_t gid = -1;
00898
00899 for (x = 0; x < AST_MAX_CONNECTS
<http://asterisk.org/doxygen/asterisk_8c.html#a2>; x++)
00900 consoles
<http://asterisk.org/doxygen/asterisk_8c.html#a24>[x].fd
<http://asterisk.org/doxygen/structconsole.html#o0> = -1;
00901 unlink(ast_config_AST_SOCKET
<http://asterisk.org/doxygen/asterisk_8c.html#a38>);
-> 00902 ast_socket
<http://asterisk.org/doxygen/asterisk_8c.html#a16> = socket(PF_LOCAL
<http://asterisk.org/doxygen/asterisk_8c.html#a1>, SOCK_STREAM, 0);
00903 if (ast_socket
<http://asterisk.org/doxygen/asterisk_8c.html#a16> < 0) {
00904 ast_log
<http://asterisk.org/doxygen/logger_8c.html#a45>(LOG_WARNING
<http://asterisk.org/doxygen/logger_8h.html#a15>, "Unable to create
control socket: %s\n", strerror(errno));
00905 return -1;
00906 }
00907 memset(&sunaddr, 0, sizeof(sunaddr));
00908 sunaddr.sun_family = AF_LOCAL
<http://asterisk.org/doxygen/asterisk_8c.html#a0>;
00909 ast_copy_string(sunaddr.sun_path, ast_config_AST_SOCKET
<http://asterisk.org/doxygen/asterisk_8c.html#a38>,
sizeof(sunaddr.sun_path));
-> 00910 res = bind(ast_socket
<http://asterisk.org/doxygen/asterisk_8c.html#a16>, (struct sockaddr
*)&sunaddr, sizeof(sunaddr));
For sipsock:
in function static int reload_config
<http://asterisk.org/doxygen/chan__h323_8c.html#a115>(enum
channelreloadreason <http://asterisk.org/doxygen/channel_8h.html#a175>
reason)
if (sipsock <http://asterisk.org/doxygen/chan__sip_8c.html#a254> < 0) {
15831 sipsock
<http://asterisk.org/doxygen/chan__sip_8c.html#a254> = socket(AF_INET,
SOCK_DGRAM, 0);
15832 if (sipsock
<http://asterisk.org/doxygen/chan__sip_8c.html#a254> < 0) {
15833 ast_log
<http://asterisk.org/doxygen/logger_8c.html#a45>(LOG_WARNING
<http://asterisk.org/doxygen/logger_8h.html#a15>, "Unable to create
SIP socket: %s\n", strerror(errno));
15834 } else {
I don't know why are these separate sockets and 1 tcp and other udp?
Thanks in advance,
Sameer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20060710/78e2fe55/attachment.htm
More information about the asterisk-dev
mailing list