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/tcpsvd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'toys/pending/tcpsvd.c') diff --git a/toys/pending/tcpsvd.c b/toys/pending/tcpsvd.c index 31c27610..e5bd76b5 100644 --- a/toys/pending/tcpsvd.c +++ b/toys/pending/tcpsvd.c @@ -248,7 +248,7 @@ static int create_bind_sock(char *host, struct sockaddr *haddr) sockfd = xsocket(rp->ai_family, TT.udp ?SOCK_DGRAM :SOCK_STREAM, 0); setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &set, sizeof(set)); if (TT.udp) setsockopt(sockfd, IPPROTO_IP, IP_PKTINFO, &set, sizeof(set)); - if ((bind(sockfd, rp->ai_addr, rp->ai_addrlen)) < 0) perror_exit("Bind failed"); + xbind(sockfd, rp->ai_addr, rp->ai_addrlen); if(haddr) memcpy(haddr, rp->ai_addr, rp->ai_addrlen); freeaddrinfo(res); return sockfd; @@ -386,8 +386,7 @@ void tcpsvd_main(void) free(serv); free(clie); } - if (TT.udp && (connect(newfd, (struct sockaddr *)buf, sizeof(buf)) < 0)) - perror_exit("connect"); + if (TT.udp) xconnect(newfd, (struct sockaddr *)buf, sizeof(buf)); close(0); close(1); -- cgit v1.2.3