summaryrefslogtreecommitdiffhomepage
path: root/libbb
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-26 01:09:46 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-26 01:09:46 +0000
commit1457915afcb8fb0697f441dce1697b278d25f4a5 (patch)
tree4f61a7fd5a6a3ebbca053c55dc68b8a3edb7700b /libbb
parent940b2e4b734e92cd6dd10c33910439478812d106 (diff)
xconnect is non-conforming to "xfunc like libc" rule. Fixing
Diffstat (limited to 'libbb')
-rw-r--r--libbb/xconnect.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index f88136a1a..7cf9d00e9 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -49,14 +49,20 @@ void bb_lookup_host(struct sockaddr_in *s_in, const char *host)
memcpy(&(s_in->sin_addr), he->h_addr_list[0], he->h_length);
}
-int xconnect(struct sockaddr_in *s_addr)
+void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen)
{
- int s = xsocket(AF_INET, SOCK_STREAM, 0);
- if (connect(s, (struct sockaddr *)s_addr, sizeof(struct sockaddr_in)) < 0)
- {
+ if (connect(s, s_addr, addrlen) < 0) {
if (ENABLE_FEATURE_CLEAN_UP) close(s);
- bb_perror_msg_and_die("unable to connect to remote host (%s)",
- inet_ntoa(s_addr->sin_addr));
+ if (s_addr->sa_family == AF_INET)
+ bb_perror_msg_and_die("unable to connect to remote host (%s)",
+ inet_ntoa(((struct sockaddr_in *)s_addr)->sin_addr));
+ bb_perror_msg_and_die("unable to connect to remote host");
}
+}
+
+int xconnect_tcp_v4(struct sockaddr_in *s_addr)
+{
+ int s = xsocket(AF_INET, SOCK_STREAM, 0);
+ xconnect(s, (struct sockaddr*) s_addr, sizeof(*s_addr));
return s;
}