aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ares/ares_process.c21
-rw-r--r--ares/windows_port.c2
-rw-r--r--tests/server/tftpd.c19
3 files changed, 20 insertions, 22 deletions
diff --git a/ares/ares_process.c b/ares/ares_process.c
index 3a60bf157..dd40238ca 100644
--- a/ares/ares_process.c
+++ b/ares/ares_process.c
@@ -197,9 +197,7 @@ static void write_tcp_data(ares_channel channel, fd_set *write_fds, time_t now)
/* Can't allocate iovecs; just send the first request. */
sendreq = server->qhead;
- scount = send(server->tcp_socket, (void *)sendreq->data,
- sendreq->len, 0);
-
+ scount = swrite(server->tcp_socket, sendreq->data, sendreq->len);
if (scount < 0)
{
if (!try_again(GET_ERRNO()))
@@ -249,9 +247,9 @@ static void read_tcp_data(ares_channel channel, fd_set *read_fds, time_t now)
/* We haven't yet read a length word, so read that (or
* what's left to read of it).
*/
- count = recv(server->tcp_socket,
- (void *)(server->tcp_lenbuf + server->tcp_lenbuf_pos),
- 2 - server->tcp_lenbuf_pos, 0);
+ count = sread(server->tcp_socket,
+ server->tcp_lenbuf + server->tcp_lenbuf_pos,
+ 2 - server->tcp_lenbuf_pos);
if (count <= 0)
{
if (!(count == -1 && try_again(GET_ERRNO())))
@@ -276,9 +274,9 @@ static void read_tcp_data(ares_channel channel, fd_set *read_fds, time_t now)
else
{
/* Read data into the allocated buffer. */
- count = recv(server->tcp_socket,
- (void *)(server->tcp_buffer + server->tcp_buffer_pos),
- server->tcp_length - server->tcp_buffer_pos, 0);
+ count = sread(server->tcp_socket,
+ server->tcp_buffer + server->tcp_buffer_pos,
+ server->tcp_length - server->tcp_buffer_pos);
if (count <= 0)
{
if (!(count == -1 && try_again(GET_ERRNO())))
@@ -320,7 +318,7 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds,
!FD_ISSET(server->udp_socket, read_fds))
continue;
- count = recv(server->udp_socket, (void *)buf, sizeof(buf), 0);
+ count = sread(server->udp_socket, buf, sizeof(buf));
if (count == -1 && try_again(GET_ERRNO()))
continue;
else if (count <= 0)
@@ -510,8 +508,7 @@ void ares__send_query(ares_channel channel, struct query *query, time_t now)
return;
}
}
- if (send(server->udp_socket, (void *)query->qbuf,
- query->qlen, 0) == -1)
+ if (swrite(server->udp_socket, query->qbuf, query->qlen) == -1)
{
/* FIXME: Handle EAGAIN here since it likely can happen. */
query->skip_server[query->server] = 1;
diff --git a/ares/windows_port.c b/ares/windows_port.c
index a2b72d538..2a326da01 100644
--- a/ares/windows_port.c
+++ b/ares/windows_port.c
@@ -102,6 +102,6 @@ ares_writev (ares_socket_t s, const struct iovec *vector, size_t count)
memcpy (bp, vector[i].iov_base, vector[i].iov_len);
bp += vector[i].iov_len;
}
- return send (s, (const void*)buffer, bytes, 0);
+ return (int)swrite(s, buffer, bytes);
}
#endif /* WIN32 builds only */
diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c
index 26e0c4044..249753ead 100644
--- a/tests/server/tftpd.c
+++ b/tests/server/tftpd.c
@@ -738,7 +738,8 @@ static void sendtftp(struct testcase *test, struct formats *pf)
struct tftphdr *dp;
struct tftphdr *ap; /* ack packet */
unsigned short block = 1;
- int size, n;
+ int size;
+ ssize_t n;
#if defined(HAVE_ALARM) && defined(SIGALRM)
mysignal(SIGALRM, timer);
#endif
@@ -757,7 +758,7 @@ static void sendtftp(struct testcase *test, struct formats *pf)
(void) sigsetjmp(timeoutbuf, 1);
#endif
send_data:
- if (send(peer, dp, size + 4, 0) != size + 4) {
+ if (swrite(peer, dp, size + 4) != size + 4) {
logmsg("write\n");
return;
}
@@ -766,7 +767,7 @@ static void sendtftp(struct testcase *test, struct formats *pf)
#ifdef HAVE_ALARM
alarm(rexmtval); /* read the ack */
#endif
- n = recv(peer, ackbuf, sizeof (ackbuf), 0);
+ n = sread(peer, ackbuf, sizeof (ackbuf));
#ifdef HAVE_ALARM
alarm(0);
#endif
@@ -828,7 +829,7 @@ static void recvtftp(struct testcase *test, struct formats *pf)
(void) sigsetjmp(timeoutbuf, 1);
#endif
send_ack:
- if (send(peer, ackbuf, 4, 0) != 4) {
+ if (swrite(peer, ackbuf, 4) != 4) {
logmsg("write: fail\n");
goto abort;
}
@@ -837,7 +838,7 @@ send_ack:
#ifdef HAVE_ALARM
alarm(rexmtval);
#endif
- n = recv(peer, dp, PKTSIZE, 0);
+ n = sread(peer, dp, PKTSIZE);
#ifdef HAVE_ALARM
alarm(0);
#endif
@@ -873,19 +874,19 @@ send_ack:
ap->th_opcode = htons((u_short)ACK); /* send the "final" ack */
ap->th_block = htons((u_short)(block));
- (void) send(peer, ackbuf, 4, 0);
+ (void) swrite(peer, ackbuf, 4);
#if defined(HAVE_ALARM) && defined(SIGALRM)
mysignal(SIGALRM, justquit); /* just quit on timeout */
alarm(rexmtval);
#endif
- n = recv(peer, buf, sizeof (buf), 0); /* normally times out and quits */
+ n = sread(peer, buf, sizeof(buf)); /* normally times out and quits */
#ifdef HAVE_ALARM
alarm(0);
#endif
if (n >= 4 && /* if read some data */
dp->th_opcode == DATA && /* and got a data block */
block == dp->th_block) { /* then my last ack was lost */
- (void) send(peer, ackbuf, 4, 0); /* resend final ack */
+ (void) swrite(peer, ackbuf, 4); /* resend final ack */
}
abort:
return;
@@ -930,6 +931,6 @@ static void nak(int error)
length = (int)strlen(pe->e_msg);
tp->th_msg[length] = '\0';
length += 5;
- if (send(peer, buf, length, 0) != length)
+ if (swrite(peer, buf, length) != length)
logmsg("nak: fail\n");
}