This patch implements non-blocking sockets for Windows in the example
programs, meaning they can now be compiled under Windows.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
diff -urN libssh2-0.18.orig/example/simple/scp_nonblock.c 
libssh2-0.18.mingw/example/simple/scp_nonblock.c
--- libssh2-0.18.orig/example/simple/scp_nonblock.c     2007-09-24 
13:15:45.000000000 +0100
+++ libssh2-0.18.mingw/example/simple/scp_nonblock.c    2008-11-10 
14:22:21.000000000 +0000
@@ -89,8 +89,13 @@
     rc = fcntl(sock, F_GETFL, 0);
     fcntl(sock, F_SETFL, rc | O_NONBLOCK);
 #else
+#ifdef WIN32
+    u_long mode = 1;
+    ioctlsocket (sock, FIONBIO, &mode);
+#else
 #error "add support for setting the socket non-blocking here"
 #endif
+#endif
 
     /* Create a session instance */
     session = libssh2_session_init();
diff -urN libssh2-0.18.orig/example/simple/scp_write_nonblock.c 
libssh2-0.18.mingw/example/simple/scp_write_nonblock.c
--- libssh2-0.18.orig/example/simple/scp_write_nonblock.c       2007-08-12 
22:39:56.000000000 +0100
+++ libssh2-0.18.mingw/example/simple/scp_write_nonblock.c      2008-11-10 
14:22:13.000000000 +0000
@@ -106,8 +106,13 @@
     rc = fcntl(sock, F_GETFL, 0);
     fcntl(sock, F_SETFL, rc | O_NONBLOCK);
 #else
+#ifdef WIN32
+    u_long mode = 1;
+    ioctlsocket (sock, FIONBIO, &mode);
+#else
 #error "add support for setting the socket non-blocking here"
 #endif
+#endif
 
     /* Create a session instance
      */
diff -urN libssh2-0.18.orig/example/simple/sftpdir_nonblock.c 
libssh2-0.18.mingw/example/simple/sftpdir_nonblock.c
--- libssh2-0.18.orig/example/simple/sftpdir_nonblock.c 2007-08-12 
22:39:56.000000000 +0100
+++ libssh2-0.18.mingw/example/simple/sftpdir_nonblock.c        2008-11-10 
14:23:35.000000000 +0000
@@ -92,8 +92,13 @@
     rc = fcntl(sock, F_GETFL, 0);
     fcntl(sock, F_SETFL, rc | O_NONBLOCK);
 #else
+#ifdef WIN32
+    u_long mode = 1;
+    ioctlsocket (sock, FIONBIO, &mode);
+#else
 #error "add support for setting the socket non-blocking here"
 #endif
+#endif
 
     /* Create a session instance
      */
diff -urN libssh2-0.18.orig/example/simple/sftp_mkdir_nonblock.c 
libssh2-0.18.mingw/example/simple/sftp_mkdir_nonblock.c
--- libssh2-0.18.orig/example/simple/sftp_mkdir_nonblock.c      2007-08-12 
22:39:56.000000000 +0100
+++ libssh2-0.18.mingw/example/simple/sftp_mkdir_nonblock.c     2008-11-10 
14:23:03.000000000 +0000
@@ -92,8 +92,13 @@
     rc = fcntl(sock, F_GETFL, 0);
     fcntl(sock, F_SETFL, rc | O_NONBLOCK);
 #else
+#ifdef WIN32
+    u_long mode = 1;
+    ioctlsocket (sock, FIONBIO, &mode);
+#else
 #error "add support for setting the socket non-blocking here"
 #endif
+#endif
 
     /* Create a session instance
      */
diff -urN libssh2-0.18.orig/example/simple/sftp_nonblock.c 
libssh2-0.18.mingw/example/simple/sftp_nonblock.c
--- libssh2-0.18.orig/example/simple/sftp_nonblock.c    2007-08-12 
22:39:56.000000000 +0100
+++ libssh2-0.18.mingw/example/simple/sftp_nonblock.c   2008-11-10 
14:22:30.000000000 +0000
@@ -95,8 +95,13 @@
     rc = fcntl(sock, F_GETFL, 0);
     fcntl(sock, F_SETFL, rc | O_NONBLOCK);
 #else
+#ifdef WIN32
+    u_long mode = 1;
+    ioctlsocket (sock, FIONBIO, &mode);
+#else
 #error "add support for setting the socket non-blocking here"
 #endif
+#endif
 
     /* Create a session instance */
     session = libssh2_session_init();
diff -urN libssh2-0.18.orig/example/simple/sftp_RW_nonblock.c 
libssh2-0.18.mingw/example/simple/sftp_RW_nonblock.c
--- libssh2-0.18.orig/example/simple/sftp_RW_nonblock.c 2007-08-12 
22:39:56.000000000 +0100
+++ libssh2-0.18.mingw/example/simple/sftp_RW_nonblock.c        2008-11-10 
14:23:18.000000000 +0000
@@ -88,8 +88,13 @@
     rc = fcntl(sock, F_GETFL, 0);
     fcntl(sock, F_SETFL, rc | O_NONBLOCK);
 #else
+#ifdef WIN32
+    u_long mode = 1;
+    ioctlsocket (sock, FIONBIO, &mode);
+#else
 #error "add support for setting the socket non-blocking here"
 #endif
+#endif
 
     /* Create a session instance
      */
diff -urN libssh2-0.18.orig/example/simple/sftp_write_nonblock.c 
libssh2-0.18.mingw/example/simple/sftp_write_nonblock.c
--- libssh2-0.18.orig/example/simple/sftp_write_nonblock.c      2007-08-12 
22:39:56.000000000 +0100
+++ libssh2-0.18.mingw/example/simple/sftp_write_nonblock.c     2008-11-10 
14:22:44.000000000 +0000
@@ -107,8 +107,13 @@
     rc = fcntl(sock, F_GETFL, 0);
     fcntl(sock, F_SETFL, rc | O_NONBLOCK);
 #else
+#ifdef WIN32
+    u_long mode = 1;
+    ioctlsocket (sock, FIONBIO, &mode);
+#else
 #error "add support for setting the socket non-blocking here"
 #endif
+#endif
 
     /* Create a session instance
         */
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
libssh2-devel mailing list
libssh2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel

Reply via email to