src/network.c

changeset 9455
b16e0c0ac03c
parent 9452
0e3cdb898d3e
child 9456
b5f072bbe9d2
equal deleted inserted replaced
9454:074ca0b0a7c5 9455:b16e0c0ac03c
176 * Go through the list of addresses and attempt to listen on 176 * Go through the list of addresses and attempt to listen on
177 * one of them. 177 * one of them.
178 * XXX - Try IPv6 addresses first? 178 * XXX - Try IPv6 addresses first?
179 */ 179 */
180 for (next = res; next != NULL; next = next->ai_next) { 180 for (next = res; next != NULL; next = next->ai_next) {
181 listenfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); 181 listenfd = socket(next->ai_family, next->ai_socktype, next->ai_protocol);
182 if (listenfd < 0) 182 if (listenfd < 0)
183 continue; 183 continue;
184 if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0) 184 if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0)
185 gaim_debug_warning("network", "setsockopt: %s\n", strerror(errno)); 185 gaim_debug_warning("network", "setsockopt: %s\n", strerror(errno));
186 if (bind(listenfd, res->ai_addr, res->ai_addrlen) == 0) 186 if (bind(listenfd, next->ai_addr, next->ai_addrlen) == 0)
187 break; /* success */ 187 break; /* success */
188 close(listenfd); 188 close(listenfd);
189 } 189 }
190 190
191 freeaddrinfo(res); 191 freeaddrinfo(res);

mercurial