patch 7.4.1169
Problem:    The socket I/O is intertwined with the netbeans code.
Solution:   Start refactoring the netbeans communication to split off the
            socket I/O.  Add the +channel feature.
diff --git a/src/os_unix.c b/src/os_unix.c
index d2e1c79..0a73c88 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -5189,9 +5189,6 @@
     int		*check_for_gpm UNUSED;
 {
     int		ret;
-#ifdef FEAT_NETBEANS_INTG
-    int		nb_fd = netbeans_filedesc();
-#endif
 #if defined(FEAT_XCLIPBOARD) || defined(USE_XSMP) || defined(FEAT_MZSCHEME)
     static int	busy = FALSE;
 
@@ -5241,7 +5238,7 @@
 # endif
 #endif
 #ifndef HAVE_SELECT
-	struct pollfd   fds[6];
+	struct pollfd   fds[6 + MAX_OPEN_CHANNELS];
 	int		nfd;
 # ifdef FEAT_XCLIPBOARD
 	int		xterm_idx = -1;
@@ -5252,9 +5249,6 @@
 # ifdef USE_XSMP
 	int		xsmp_idx = -1;
 # endif
-# ifdef FEAT_NETBEANS_INTG
-	int		nb_idx = -1;
-# endif
 	int		towait = (int)msec;
 
 # ifdef FEAT_MZSCHEME
@@ -5306,14 +5300,8 @@
 	    nfd++;
 	}
 # endif
-#ifdef FEAT_NETBEANS_INTG
-	if (nb_fd != -1)
-	{
-	    nb_idx = nfd;
-	    fds[nfd].fd = nb_fd;
-	    fds[nfd].events = POLLIN;
-	    nfd++;
-	}
+#ifdef FEAT_CHANNEL
+	nfd = channel_poll_setup(nfd, &fds);
 #endif
 
 	ret = poll(fds, nfd, towait);
@@ -5368,12 +5356,9 @@
 		finished = FALSE;	/* Try again */
 	}
 # endif
-#ifdef FEAT_NETBEANS_INTG
-	if (ret > 0 && nb_idx != -1 && fds[nb_idx].revents & POLLIN)
-	{
-	    netbeans_read();
-	    --ret;
-	}
+#ifdef FEAT_CHANNEL
+	if (ret > 0)
+	    ret = channel_poll_check(ret, &fds);
 #endif
 
 
@@ -5462,13 +5447,8 @@
 		maxfd = xsmp_icefd;
 	}
 # endif
-# ifdef FEAT_NETBEANS_INTG
-	if (nb_fd != -1)
-	{
-	    FD_SET(nb_fd, &rfds);
-	    if (maxfd < nb_fd)
-		maxfd = nb_fd;
-	}
+# ifdef FEAT_CHANNEL
+	maxfd = channel_select_setup(maxfd, &rfds);
 # endif
 
 	ret = select(maxfd + 1, &rfds, NULL, &efds, tvp);
@@ -5556,12 +5536,9 @@
 	    }
 	}
 # endif
-#ifdef FEAT_NETBEANS_INTG
-	if (ret > 0 && nb_fd != -1 && FD_ISSET(nb_fd, &rfds))
-	{
-	    netbeans_read();
-	    --ret;
-	}
+#ifdef FEAT_CHANNEL
+	if (ret > 0)
+	    ret = channel_select_check(ret, &rfds);
 #endif
 
 #endif /* HAVE_SELECT */