Only use recv/send for socket BIOs on Windows.

In OpenSSL, socket BIOs only used recv/send on Windows and read/write on POSIX.
Align our socket BIOs with that behavior. This should be a no-op, but avoids
frustrating consumers overly sensitive to the syscalls used now that SSL_set_fd
has switched to socket BIOs to align with OpenSSL. b/28138582.

Change-Id: Id4870ef8e668e587d6ef51c5b5f21e03af66a288
Reviewed-on: https://boringssl-review.googlesource.com/7686
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/bio/socket.c b/crypto/bio/socket.c
index 98f32a6..3ef6967 100644
--- a/crypto/bio/socket.c
+++ b/crypto/bio/socket.c
@@ -110,7 +110,11 @@
   }
 
   bio_clear_socket_error();
+#if defined(OPENSSL_WINDOWS)
   ret = recv(b->num, out, outl, 0);
+#else
+  ret = read(b->num, out, outl);
+#endif
   BIO_clear_retry_flags(b);
   if (ret <= 0) {
     if (bio_fd_should_retry(ret)) {
@@ -124,7 +128,11 @@
   int ret;
 
   bio_clear_socket_error();
+#if defined(OPENSSL_WINDOWS)
   ret = send(b->num, in, inl, 0);
+#else
+  ret = write(b->num, in, inl);
+#endif
   BIO_clear_retry_flags(b);
   if (ret <= 0) {
     if (bio_fd_should_retry(ret)) {
diff --git a/include/openssl/bio.h b/include/openssl/bio.h
index 2168812..a7fe261 100644
--- a/include/openssl/bio.h
+++ b/include/openssl/bio.h
@@ -529,9 +529,9 @@
 
 /* Socket BIOs.
  *
- * Socket BIOs behave like file descriptor BIOs but wrap the system's |recv|
- * and |send| functions. This is relevant for Windows systems where file
- * descriptors, provided by C runtime for use with |read| and |write|, are not
+ * Socket BIOs behave like file descriptor BIOs but, on Windows systems, wrap
+ * the system's |recv| and |send| functions instead of |read| and |write|. On
+ * Windows, file descriptors are provided by C runtime and are not
  * interchangeable with sockets.
  *
  * Socket BIOs may be used with |BIO_set_fd| and |BIO_get_fd|.