Commit e6e3a796 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a VSS_bind() function, using the meat of VSS_listen()


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2657 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 929ed14f
......@@ -32,5 +32,6 @@ struct vss_addr;
int VSS_parse(const char *str, char **addr, char **port);
int VSS_resolve(const char *addr, const char *port, struct vss_addr ***ta);
int VSS_bind(const struct vss_addr *addr);
int VSS_listen(const struct vss_addr *addr, int depth);
int VSS_connect(const struct vss_addr *addr);
......@@ -165,14 +165,15 @@ VSS_resolve(const char *addr, const char *port, struct vss_addr ***vap)
}
/*
* Given a struct vss_addr, open a socket of the appropriate type, bind it
* to the requested address, and start listening.
* Given a struct vss_addr, open a socket of the appropriate type, and bind
* it to the requested address.
*
* If the address is an IPv6 address, the IPV6_V6ONLY option is set to
* avoid conflicts between INADDR_ANY and IN6ADDR_ANY.
*/
int
VSS_listen(const struct vss_addr *va, int depth)
VSS_bind(const struct vss_addr *va)
{
int sd, val;
......@@ -202,10 +203,28 @@ VSS_listen(const struct vss_addr *va, int depth)
(void)close(sd);
return (-1);
}
if (listen(sd, depth) != 0) {
perror("listen()");
(void)close(sd);
return (-1);
return (sd);
}
/*
* Given a struct vss_addr, open a socket of the appropriate type, bind it
* to the requested address, and start listening.
*
* If the address is an IPv6 address, the IPV6_V6ONLY option is set to
* avoid conflicts between INADDR_ANY and IN6ADDR_ANY.
*/
int
VSS_listen(const struct vss_addr *va, int depth)
{
int sd;
sd = VSS_bind(va);
if (sd >= 0) {
if (listen(sd, depth) != 0) {
perror("listen()");
(void)close(sd);
return (-1);
}
}
return (sd);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment