More care with time types
[exim.git] / src / src / ip.c
index a820998ca082ec3a22e036024376860169b91b09..b492b9da1566d0c03dcc8aec11e4356aa458749e 100644 (file)
@@ -2,7 +2,7 @@
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2013 */
+/* Copyright (c) University of Cambridge 1995 - 2014 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 /* Functions for doing things with sockets. With the advent of IPv6 this has
@@ -248,8 +248,14 @@ return -1;
 }
 
 
+
+/*************************************************
+*    Create connected socket to remote host      *
+*************************************************/
+
 /* Create a socket and connect to host (name or number, ipv6 ok)
    at one of port-range.
+
 Arguments:
   type          SOCK_DGRAM or SOCK_STREAM
   af            AF_INET6 or AF_INET for the socket type
@@ -317,8 +323,8 @@ else
 for (h = &shost; h != NULL; h = h->next)
   {
   fd = (Ustrchr(h->address, ':') != 0)
-    ? (fd6 < 0) ? (fd6 = ip_socket(SOCK_STREAM, af = AF_INET6)) : fd6
-    : (fd4 < 0) ? (fd4 = ip_socket(SOCK_STREAM, af = AF_INET )) : fd4;
+    ? (fd6 < 0) ? (fd6 = ip_socket(type, af = AF_INET6)) : fd6
+    : (fd4 < 0) ? (fd4 = ip_socket(type, af = AF_INET )) : fd4;
 
   if (fd < 0)
     {
@@ -340,8 +346,8 @@ for (h = &shost; h != NULL; h = h->next)
       }
   }
 
-*errstr = string_sprintf("failed to connect to "
-  "%s: couldn't connect to any host", hostname, strerror(errno));
+*errstr = string_sprintf("failed to connect to %s: "
+  "couldn't connect to any host: %s", hostname, strerror(errno));
 
 bad:
   close(fd4); close(fd6); return -1;
@@ -397,7 +403,7 @@ ip_recv(int sock, uschar *buffer, int buffsize, int timeout)
 {
 fd_set select_inset;
 struct timeval tv;
-int start_recv = time(NULL);
+time_t start_recv = time(NULL);
 int rc;
 
 /* Wait until the socket is ready */