o Add new utility functions to correctly observe and log winsock errors.
o Do not remove Accept-Encoding header
o Clear the timer cache on entering the event loop; reported by Victor Chang
+ o Only bind the socket on connect when a local address has been provided; reported by Alejo Sanchez
Changes in 1.4.0:
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
*pport = mm_strdup(strport);
}
-/* Either connect or bind */
-
+/* Create a non-blocking socket and bind it */
+/* todo: rename this function */
static evutil_socket_t
bind_socket_ai(struct addrinfo *ai, int reuse)
{
(void *)&on, sizeof(on));
}
- r = bind(fd, ai->ai_addr, ai->ai_addrlen);
- if (r == -1)
- goto out;
+ if (ai != NULL) {
+ r = bind(fd, ai->ai_addr, ai->ai_addrlen);
+ if (r == -1)
+ goto out;
+ }
return (fd);
bind_socket(const char *address, ev_uint16_t port, int reuse)
{
evutil_socket_t fd;
- struct addrinfo *aitop = make_addrinfo(address, port);
+ struct addrinfo *aitop = NULL;
+
+ /* just create an unbound socket */
+ if (address == NULL && port == 0)
+ return bind_socket_ai(NULL, 0);
+
+ aitop = make_addrinfo(address, port);
if (aitop == NULL)
return (-1);