From a57721d14642291696be4ffd5d8bb0915fbe861b Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 8 Jul 2019 16:02:56 -0700 Subject: bind/connect cleanup. Rename the existing xbind/xconnect to xbindany/xconnectany, to make room for new xbind/xconnect that are more like 'x' versions of the regular bind and connect. Move explicit bind/connect callers over to xbind/xconnect. Of the affected commands, only netcat is actually used by Android. It was the most recent patch to netcat that made the lack of a more traditional xbind/xconnect apparent. --- toys/pending/host.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'toys/pending/host.c') diff --git a/toys/pending/host.c b/toys/pending/host.c index fa830a7d..fe0f23aa 100644 --- a/toys/pending/host.c +++ b/toys/pending/host.c @@ -121,9 +121,8 @@ void host_main(void) if ((ret = getaddrinfo(nsname, "53", &ns_hints, &ai)) < 0) error_exit("Error looking up server name: %s", gai_strerror(ret)); - int s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); - if (s < 0 || connect(s, ai->ai_addr, ai->ai_addrlen) < 0) - perror_exit("Socket error"); + int s = xsocket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); + xconnect(s, ai->ai_addr, ai->ai_addrlen); setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &(struct timeval){ .tv_sec = 5 }, sizeof(struct timeval)); printf("Using domain server %s:\n", nsname); -- cgit v1.2.3