From a94383037c60ae9ad87a0809be436cf3a9e74248 Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Mon, 2 May 2016 10:10:25 -0600 Subject: [PATCH] use send/recv instead of write/read with STARTTLS for winsock compatibility --- examples/client/client.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/client/client.c b/examples/client/client.c index ab4436341..639325a03 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -345,7 +345,7 @@ int StartTLS_Init(SOCKET_T* sockfd) return BAD_FUNC_ARG; /* S: 220 SMTP service ready */ - if (read(*sockfd, tmpBuf, sizeof(tmpBuf)) < 0) + if (recv(*sockfd, tmpBuf, sizeof(tmpBuf), 0) < 0) err_sys("failed to read STARTTLS command\n"); if (!XSTRNCMP(tmpBuf, starttlsCmd[0], XSTRLEN(starttlsCmd[0]))) { @@ -356,12 +356,12 @@ int StartTLS_Init(SOCKET_T* sockfd) } /* C: EHLO mail.example.com */ - if (write(*sockfd, starttlsCmd[1], XSTRLEN(starttlsCmd[1])) != - (int)XSTRLEN(starttlsCmd[1])) + if (send(*sockfd, starttlsCmd[1], (int)XSTRLEN(starttlsCmd[1]), 0) != + (word32)XSTRLEN(starttlsCmd[1])) err_sys("failed to send STARTTLS EHLO command\n"); /* S: 250 offers a warm hug of welcome */ - if (read(*sockfd, tmpBuf, sizeof(tmpBuf)) < 0) + if (recv(*sockfd, tmpBuf, sizeof(tmpBuf), 0) < 0) err_sys("failed to read STARTTLS command\n"); if (!XSTRNCMP(tmpBuf, starttlsCmd[2], XSTRLEN(starttlsCmd[2]))) { @@ -372,13 +372,13 @@ int StartTLS_Init(SOCKET_T* sockfd) } /* C: STARTTLS */ - if (write(*sockfd, starttlsCmd[3], XSTRLEN(starttlsCmd[3])) != - (int)XSTRLEN(starttlsCmd[3])) { + if (send(*sockfd, starttlsCmd[3], (int)XSTRLEN(starttlsCmd[3]), 0) != + (word32)XSTRLEN(starttlsCmd[3])) { err_sys("failed to send STARTTLS command\n"); } /* S: 220 Go ahead */ - if (read(*sockfd, tmpBuf, sizeof(tmpBuf)) < 0) + if (recv(*sockfd, tmpBuf, sizeof(tmpBuf), 0) < 0) err_sys("failed to read STARTTLS command\n"); if (!XSTRNCMP(tmpBuf, starttlsCmd[4], XSTRLEN(starttlsCmd[4]))) {