[asterisk-commits] russell: branch 1.2 r59608 -
/branches/1.2/netsock.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sun Apr 1 15:35:26 MST 2007
Author: russell
Date: Sun Apr 1 17:35:25 2007
New Revision: 59608
URL: http://svn.digium.com/view/asterisk?view=rev&rev=59608
Log:
Add the SO_REUSEADDR flag to sockets handled by netsock. This is needed by
the patch that went in for issue 7874. chan_iax2 needs to be able to create
socket that is lisetning on INADDR_ANY, but also be able to bind sockets to
specific addresses. (Thanks to Stevenson on the asterisk-dev mailing list
for explaining why this flag was needed.)
Modified:
branches/1.2/netsock.c
Modified: branches/1.2/netsock.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/netsock.c?view=diff&rev=59608&r1=59607&r2=59608
==============================================================================
--- branches/1.2/netsock.c (original)
+++ branches/1.2/netsock.c Sun Apr 1 17:35:25 2007
@@ -128,6 +128,7 @@
char iabuf[INET_ADDRSTRLEN];
struct ast_netsock *ns;
+ const int reuseFlag = 1;
/* Make a UDP socket */
netsocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
@@ -136,6 +137,8 @@
ast_log(LOG_ERROR, "Unable to create network socket: %s\n", strerror(errno));
return NULL;
}
+ if (setsockopt(netsocket, SOL_SOCKET, SO_REUSEADDR, (char *)&reuseFlag, sizeof reuseFlag) < 0)
+ ast_log(LOG_WARNING, "Error setting SO_REUSEADDR on sockfd '%d'\n", netsocket);
if (bind(netsocket,(struct sockaddr *)bindaddr, sizeof(struct sockaddr_in))) {
ast_log(LOG_ERROR, "Unable to bind to %s port %d: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr->sin_addr), ntohs(bindaddr->sin_port), strerror(errno));
close(netsocket);
More information about the asterisk-commits
mailing list