    time_t t = time (0);
    blocknotify_t bn = (blocknotify_t) mail_parameters (NIL,GET_BLOCKNOTIFY,NIL);
    if (stream->tcpso < 0) return NIL;
-@@ -689,15 +666,12 @@ long tcp_sout (TCPSTREAM *stream,char *string,unsigned long size)
+@@ -689,15 +666,12 @@
      time_t now = tl;
      time_t ti = ttmo_write ? now + ttmo_write : 0;
      if (tcpdebug) mm_log ("Writing to TCP",TCPDEBUG);

 
 
 #include "fs_unix.c"
diff --git a/src/osdep/unix/tcp_unix.c b/src/osdep/unix/tcp_unix.c
index 795fb4f..c69eaec 100644
--- a/src/osdep/unix/tcp_unix.c
+++ b/src/osdep/unix/tcp_unix.c
@@ -235,12 +235,11 @@ TCPSTREAM *tcp_open (char *host,char *service,unsigned long port)
 int tcp_socket_open (int family,void *adr,size_t adrlen,unsigned short port,
 		     char *tmp,int *ctr,char *hst)
 {

       now = time (0);		/* fake timeout if interrupt & time expired */
       if ((i < 0) && (errno == EINTR) && ti && (ti <= now)) i = 0;
     } while ((i < 0) && (errno == EINTR));
Index: uw-imap/src/osdep/unix/ssl_unix.c
===================================================================
--- uw-imap.orig/src/osdep/unix/ssl_unix.c	2014-06-04 15:34:16.000000000 +0100
+++ uw-imap/src/osdep/unix/ssl_unix.c	2014-06-04 15:34:21.000000000 +0100
@@ -472,16 +472,14 @@
 
 long ssl_getdata (SSLSTREAM *stream)
 {
-  int i,sock;
-  fd_set fds,efds;
-  struct timeval tmo;
+  int i,sock,tmo;
+  struct pollfd pfd;
   tcptimeout_t tmoh = (tcptimeout_t) mail_parameters (NIL,GET_TIMEOUT,NIL);
   long ttmo_read = (long) mail_parameters (NIL,GET_READTIMEOUT,NIL);
   time_t t = time (0);
   blocknotify_t bn = (blocknotify_t) mail_parameters (NIL,GET_BLOCKNOTIFY,NIL);
   if (!stream->con || ((sock = SSL_get_fd (stream->con)) < 0)) return NIL;
 				/* tcp_unix should have prevented this */
-  if (sock >= FD_SETSIZE) fatal ("unselectable socket in ssl_getdata()");
   (*bn) (BLOCK_TCPREAD,NIL);
   while (stream->ictr < 1) {	/* if nothing in the buffer */
     time_t tl = time (0);	/* start of request */
@@ -490,15 +488,12 @@
     if (SSL_pending (stream->con)) i = 1;
     else {
       if (tcpdebug) mm_log ("Reading SSL data",TCPDEBUG);
-      tmo.tv_usec = 0;
-      FD_ZERO (&fds);		/* initialize selection vector */
-      FD_ZERO (&efds);		/* handle errors too */
-      FD_SET (sock,&fds);	/* set bit in selection vector */
-      FD_SET (sock,&efds);	/* set bit in error selection vector */
+      pfd.fd = soc;
+      pfd.events = POLLIN;
       errno = NIL;		/* block and read */
       do {			/* block under timeout */
-	tmo.tv_sec = ti ? ti - now : 0;
-	i = select (sock+1,&fds,0,&efds,ti ? &tmo : 0);
+	tmo = ti ? ti - now : 0;
+	i = poll (&pfd, 1, ti ? tmo * 1000 : -1);
 	now = time (0);		/* fake timeout if interrupt & time expired */
 	if ((i < 0) && (errno == EINTR) && ti && (ti <= now)) i = 0;
       } while ((i < 0) && (errno == EINTR));
