diff -Naur ./include/libssh2.h ../new/include/libssh2.h
--- ./include/libssh2.h	Sun Nov 11 19:41:52 2007
+++ ../new/include/libssh2.h	Fri Sep 26 16:05:26 2008
@@ -42,6 +42,10 @@
 extern "C" {
 #endif
 
+#if defined(WIN32) && !defined(ssize_t)
+#define ssize_t int
+#endif
+
 #include <stddef.h>
 #include <string.h>
 #include <sys/stat.h>
@@ -240,6 +244,10 @@
 #define LIBSSH2_POLLFD_CHANNEL_CLOSED   0x0080      /* Channel Disconnect */
 #define LIBSSH2_POLLFD_LISTENER_CLOSED  0x0080      /* Listener Disconnect */
 
+/* Block Direction Types */
+#define LIBSSH2_SOCKET_BLOCK_INBOUND						0
+#define LIBSSH2_SOCKET_BLOCK_OUTBOUND						1
+
 /* Hash Types */
 #define LIBSSH2_HOSTKEY_HASH_MD5                            1
 #define LIBSSH2_HOSTKEY_HASH_SHA1                           2
@@ -320,6 +328,7 @@
 LIBSSH2_API const char *libssh2_session_methods(LIBSSH2_SESSION *session, int method_type);
 LIBSSH2_API int libssh2_session_last_error(LIBSSH2_SESSION *session, char **errmsg, int *errmsg_len, int want_buf);
 LIBSSH2_API int libssh2_session_last_errno(LIBSSH2_SESSION *session);
+LIBSSH2_API int libssh2_session_block_direction(LIBSSH2_SESSION *session);
 
 LIBSSH2_API int libssh2_session_flag(LIBSSH2_SESSION *session, int flag, int value);
 
diff -Naur ./src/libssh2_priv.h ../new/src/libssh2_priv.h
--- ./src/libssh2_priv.h	Sat Aug 11 07:30:30 2007
+++ ../new/src/libssh2_priv.h	Fri Sep 26 16:54:38 2008
@@ -51,7 +51,6 @@
    http://www.mail-archive.com/libssh2-devel%40lists.sourceforge.net/msg00003.html
    http://www.mail-archive.com/libssh2-devel%40lists.sourceforge.net/msg00224.html
 */
-#include <stdio.h>
 
 #ifdef HAVE_POLL
 # include <sys/poll.h>
@@ -654,6 +653,7 @@
     int socket_fd;
     int socket_block;
     int socket_state;
+    int socket_block_direction;
 
     /* Error tracking */
     char *err_msg;
diff -Naur ./src/session.c ../new/src/session.c
--- ./src/session.c	Fri Nov  9 00:11:34 2007
+++ ../new/src/session.c	Fri Sep 26 16:53:36 2008
@@ -133,6 +133,7 @@
             }
 #endif /* WIN32 */
             if (errno == EAGAIN) {
+                session->socket_block_direction = LIBSSH2_SOCKET_BLOCK_INBOUND;
                 session->banner_TxRx_total_send = banner_len;
                 return PACKET_EAGAIN;
             }
@@ -235,6 +236,7 @@
     if (ret != (banner_len - session->banner_TxRx_total_send)) {
         if ((ret > 0) || ((ret == -1) && (errno == EAGAIN))) {
             /* the whole packet could not be sent, save the what was */
+            session->socket_block_direction = LIBSSH2_SOCKET_BLOCK_OUTBOUND;
             session->banner_TxRx_total_send += ret;
             return PACKET_EAGAIN;
         }
@@ -1530,6 +1532,17 @@
     } while ((timeout_remaining > 0) && !active_fds);
 
     return active_fds;
+}
+
+/* {{{ libssh2_session_block_direction
+ * Get blocked direction when a function returns LIBSSH2_ERROR_EAGAIN
+ * Returns LIBSSH2_SOCKET_BLOCK_INBOUND if recv() blocked
+ * or LIBSSH2_SOCKET_BLOCK_OUTBOUND if send() blocked
+ */
+LIBSSH2_API int
+libssh2_session_block_direction(LIBSSH2_SESSION *session)
+{
+    return session->socket_block_direction;
 }
 
 /* }}} */
diff -Naur ./src/transport.c ../new/src/transport.c
--- ./src/transport.c	Fri Nov  9 00:11:34 2007
+++ ../new/src/transport.c	Fri Sep 26 16:54:04 2008
@@ -351,6 +351,7 @@
                 }
 #endif /* WIN32 */
                 if ((nread < 0) && (errno == EAGAIN)) {
+                    session->socket_block_direction = LIBSSH2_SOCKET_BLOCK_INBOUND;
                     return PACKET_EAGAIN;
                 }
                 return PACKET_FAIL;
@@ -587,6 +588,7 @@
             /* send failure! */
             return PACKET_FAIL;
         }
+        session->socket_block_direction = LIBSSH2_SOCKET_BLOCK_OUTBOUND;
         return PACKET_EAGAIN;
     }
 
@@ -739,6 +741,7 @@
     if (ret != total_length) {
         if ((ret > 0) || ((ret == -1) && (errno == EAGAIN))) {
             /* the whole packet could not be sent, save the rest */
+            session->socket_block_direction = LIBSSH2_SOCKET_BLOCK_OUTBOUND;
             p->odata = orgdata;
             p->olen = orgdata_len;
             p->osent = (ret == -1) ? 0 : ret;
