diff --git a/lib/ftp.c b/lib/ftp.c
index e77298228d4cbdbd2ba83af1d93b1ab361c8a673..9539419685d964ab9337fc5f89a3f63794d7758c 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -54,6 +54,9 @@
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
 #endif
+#ifdef	VMS
+#include <inet.h>
+#endif
 #endif
 
 #if defined(WIN32) && defined(__GNUC__) || defined(__MINGW32__)
@@ -489,7 +492,11 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
 
   /* The first thing we do is wait for the "220*" line: */
   nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+  if((signed int)nread < 0)
+#else
   if(nread < 0)
+#endif
     return CURLE_OPERATION_TIMEOUTED;
 
   if(ftpcode != 220) {
@@ -520,7 +527,11 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
 
   /* wait for feedback */
   nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+  if((signed int)nread < 0)
+#else
   if(nread < 0)
+#endif
     return CURLE_OPERATION_TIMEOUTED;
 
   if(ftpcode == 530) {
@@ -534,7 +545,11 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
        (the server requires to send the user's password too) */
     ftpsendf(conn->firstsocket, conn, "PASS %s", ftp->passwd);
     nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+    if((signed int)nread < 0)
+#else
     if(nread < 0)
+#endif
       return CURLE_OPERATION_TIMEOUTED;
 
     if(ftpcode == 530) {
@@ -582,7 +597,11 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
 
   /* wait for feedback */
   nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+  if((signed int)nread < 0)
+#else
   if(nread < 0)
+#endif
     return CURLE_OPERATION_TIMEOUTED;
 
   if(ftpcode == 257) {
@@ -675,7 +694,11 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
     /* now let's see what the server says about the transfer we
        just performed: */
     nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+    if((signed int)nread < 0)
+#else
     if(nread < 0)
+#endif
       return CURLE_OPERATION_TIMEOUTED;
 
     /* 226 Transfer complete, 250 Requested file action okay, completed. */
@@ -697,7 +720,11 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
         ftpsendf(conn->firstsocket, conn, "%s", qitem->data);
 
         nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+        if((signed int)nread < 0)
+#else
         if(nread < 0)
+#endif
           return CURLE_OPERATION_TIMEOUTED;
 
         if (ftpcode >= 400) {
@@ -771,7 +798,11 @@ CURLcode _ftp(struct connectdata *conn)
        where we ended up after login: */
     ftpsendf(conn->firstsocket, conn, "CWD %s", ftp->entrypath);
     nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+    if((signed int)nread < 0)
+#else
     if(nread < 0)
+#endif
       return CURLE_OPERATION_TIMEOUTED;
     
     if(ftpcode != 250) {
@@ -786,7 +817,11 @@ CURLcode _ftp(struct connectdata *conn)
   if(ftp->dir && ftp->dir[0]) {
     ftpsendf(conn->firstsocket, conn, "CWD %s", ftp->dir);
     nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+    if((signed int)nread < 0)
+#else
     if(nread < 0)
+#endif
       return CURLE_OPERATION_TIMEOUTED;
 
     if(ftpcode != 250) {
@@ -801,7 +836,11 @@ CURLcode _ftp(struct connectdata *conn)
     ftpsendf(conn->firstsocket, conn, "MDTM %s", ftp->file);
 
     nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+    if((signed int)nread < 0)
+#else
     if(nread < 0)
+#endif
       return CURLE_OPERATION_TIMEOUTED;
 
     if(ftpcode == 213) {
@@ -838,7 +877,11 @@ CURLcode _ftp(struct connectdata *conn)
              (data->bits.ftp_ascii)?"A":"I");
 
     nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+    if((signed int)nread < 0)
+#else
     if(nread < 0)
+#endif
       return CURLE_OPERATION_TIMEOUTED;
 
     if(ftpcode != 200) {
@@ -1043,7 +1086,11 @@ CURLcode _ftp(struct connectdata *conn)
       }
 
       nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
-      if (nread < 0)
+#ifdef VMS
+      if((signed int)nread < 0)
+#else
+      if(nread < 0)
+#endif
 	return CURLE_OPERATION_TIMEOUTED;
 
       if (ftpcode != 200) {
@@ -1161,7 +1208,11 @@ again:;
     }
 
     nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+    if((signed int)nread < 0)
+#else
     if(nread < 0)
+#endif
       return CURLE_OPERATION_TIMEOUTED;
 
     if(ftpcode != 200) {
@@ -1184,7 +1235,11 @@ again:;
     for (modeoff = 0; mode[modeoff]; modeoff++) {
       ftpsendf(conn->firstsocket, conn, mode[modeoff]);
       nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+      if((signed int)nread < 0)
+#else
       if(nread < 0)
+#endif
 	return CURLE_OPERATION_TIMEOUTED;
 
       if (ftpcode == results[modeoff])
@@ -1430,7 +1485,11 @@ again:;
           (data->bits.ftp_ascii)?"A":"I");
 
     nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+    if((signed int)nread < 0)
+#else
     if(nread < 0)
+#endif
       return CURLE_OPERATION_TIMEOUTED;
 
     if(ftpcode != 200) {
@@ -1461,7 +1520,11 @@ again:;
         ftpsendf(conn->firstsocket, conn, "SIZE %s", ftp->file);
 
         nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+        if((signed int)nread < 0)
+#else
         if(nread < 0)
+#endif
           return CURLE_OPERATION_TIMEOUTED;
 
         if(ftpcode != 213) {
@@ -1531,7 +1594,11 @@ again:;
       ftpsendf(conn->firstsocket, conn, "STOR %s", ftp->file);
 
     nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+    if((signed int)nread < 0)
+#else
     if(nread < 0)
+#endif
       return CURLE_OPERATION_TIMEOUTED;
 
     if(ftpcode>=400) {
@@ -1612,7 +1679,11 @@ again:;
       ftpsendf(conn->firstsocket, conn, "TYPE A");
 	
       nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+      if((signed int)nread < 0)
+#else
       if(nread < 0)
+#endif
         return CURLE_OPERATION_TIMEOUTED;
 	
       if(ftpcode != 200) {
@@ -1634,7 +1705,11 @@ again:;
                (data->bits.ftp_ascii)?"A":"I");
 
       nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+      if((signed int)nread < 0)
+#else
       if(nread < 0)
+#endif
         return CURLE_OPERATION_TIMEOUTED;
 
       if(ftpcode != 200) {
@@ -1655,7 +1730,11 @@ again:;
         ftpsendf(conn->firstsocket, conn, "SIZE %s", ftp->file);
 
         nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+        if((signed int)nread < 0)
+#else
         if(nread < 0)
+#endif
           return CURLE_OPERATION_TIMEOUTED;
 
         if(ftpcode != 213) {
@@ -1712,7 +1791,11 @@ again:;
         ftpsendf(conn->firstsocket, conn, "REST %d", conn->resume_from);
 
         nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+        if((signed int)nread < 0)
+#else
         if(nread < 0)
+#endif
           return CURLE_OPERATION_TIMEOUTED;
 
         if(ftpcode != 350) {
@@ -1725,7 +1808,11 @@ again:;
     }
 
     nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
+#ifdef VMS
+    if((signed int)nread < 0)
+#else
     if(nread < 0)
+#endif
       return CURLE_OPERATION_TIMEOUTED;
 
     if((ftpcode == 150) || (ftpcode == 125)) {