diff -Naur ./docs/Makefile.am ../new/docs/Makefile.am
--- ./docs/Makefile.am	Mon Jun 25 21:08:10 2007
+++ ../new/docs/Makefile.am	Wed Oct  1 18:46:21 2008
@@ -28,6 +28,7 @@
 	libssh2_scp_recv.3 \
 	libssh2_scp_send_ex.3 \
 	libssh2_session_abstract.3 \
+	libssh2_session_block_directions.3 \
 	libssh2_session_callback_set.3 \
 	libssh2_session_free.3 \
 	libssh2_session_disconnect_ex.3 \
diff -Naur ./docs/Makefile.in ../new/docs/Makefile.in
--- ./docs/Makefile.in	Tue Jul 31 19:02:52 2007
+++ ../new/docs/Makefile.in	Wed Oct  1 18:46:30 2008
@@ -199,6 +199,7 @@
 	libssh2_scp_recv.3 \
 	libssh2_scp_send_ex.3 \
 	libssh2_session_abstract.3 \
+	libssh2_session_block_directions.3 \
 	libssh2_session_callback_set.3 \
 	libssh2_session_free.3 \
 	libssh2_session_disconnect_ex.3 \
diff -Naur ./docs/libssh2_session_block_directions.3 ../new/docs/libssh2_session_block_directions.3
--- ./docs/libssh2_session_block_directions.3	Thu Jan  1 09:00:00 1970
+++ ../new/docs/libssh2_session_block_directions.3	Wed Oct  1 17:57:23 2008
@@ -0,0 +1,29 @@
+.\" $Id: libssh2_session_block_directions.3,v 1.0 2008/10/01 19:02:00 jehousley Exp $
+.\"
+.TH libssh2_session_block_directions 3 "1 Oct 2008" "libssh2 0.18" "libssh2 manual"
+.SH NAME
+libssh2_session_block_directions - get directions that socket should wait for before calling libssh2 function again
+.SH SYNOPSIS
+#include <libssh2.h>
+
+int
+libssh2_session_block_directions(LIBSSH2_SESSION *session);
+
+.SH DESCRIPTION
+\fIsession\fP - Session instance as returned by 
+.BR libssh2_session_init(3)
+
+When any of libssh2 functions return LIBSSH2_ERROR_EAGAIN an application should wait for the socket
+to have data available for reading or writing. Depending on the return value of
+\fIlibssh2_session_block_directions\fP an application should wait for read, write or both.
+
+.SH RETURN VALUE
+Returns the set of directions as a binary mask. Can be a combination of:
+
+LIBSSH2_SESSION_BLOCK_INBOUND: Inbound direction blocked.
+
+LIBSSH2_SESSION_BLOCK_OUTBOUND: Outbound direction blocked.
+
+Application should wait for data to ba available for socket prior to calling a libssh2 function again.
+If LIBSSH2_SESSION_BLOCK_INBOUND is set select should contain the session socket in readfds set.
+Correspondingly in case of LIBSSH2_SESSION_BLOCK_INBOUND writefds set should contain the socket.
+
+.SH SEE ALSO
+.BR libssh2_session_init(3)
diff -Naur ./include/libssh2.h ../new/include/libssh2.h
--- ./include/libssh2.h	Sun Nov 11 19:41:52 2007
+++ ../new/include/libssh2.h	Wed Oct  1 17:24:40 2008
@@ -240,6 +244,11 @@
 #define LIBSSH2_POLLFD_CHANNEL_CLOSED   0x0080      /* Channel Disconnect */
 #define LIBSSH2_POLLFD_LISTENER_CLOSED  0x0080      /* Listener Disconnect */
 
+#define HAVE_LIBSSH2_SESSION_BLOCK_DIRECTION
+/* Block Direction Types */
+#define LIBSSH2_SESSION_BLOCK_INBOUND                  0x0001
+#define LIBSSH2_SESSION_BLOCK_OUTBOUND                 0x0002
+
 /* Hash Types */
 #define LIBSSH2_HOSTKEY_HASH_MD5                            1
 #define LIBSSH2_HOSTKEY_HASH_SHA1                           2
@@ -320,6 +329,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_directions(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	Wed Oct  1 14:02:36 2008
@@ -654,6 +653,7 @@
     int socket_fd;
     int socket_block;
     int socket_state;
+    int socket_block_directions;
 
     /* 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	Wed Oct  1 14:02:49 2008
@@ -133,6 +133,7 @@
             }
 #endif /* WIN32 */
             if (errno == EAGAIN) {
+                session->socket_block_directions = LIBSSH2_SESSION_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_directions = LIBSSH2_SESSION_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_directions(LIBSSH2_SESSION *session)
+{
+    return session->socket_block_directions;
 }
 
 /* }}} */
diff -Naur ./src/transport.c ../new/src/transport.c
--- ./src/transport.c	Fri Nov  9 00:11:34 2007
+++ ../new/src/transport.c	Wed Oct  1 14:02:49 2008
@@ -351,6 +351,7 @@
                 }
 #endif /* WIN32 */
                 if ((nread < 0) && (errno == EAGAIN)) {
+                    session->socket_block_directions = LIBSSH2_SESSION_BLOCK_INBOUND;
                     return PACKET_EAGAIN;
                 }
                 return PACKET_FAIL;
@@ -587,6 +588,7 @@
             /* send failure! */
             return PACKET_FAIL;
         }
+        session->socket_block_directions = LIBSSH2_SESSION_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_directions = LIBSSH2_SESSION_BLOCK_OUTBOUND;
             p->odata = orgdata;
             p->olen = orgdata_len;
             p->osent = (ret == -1) ? 0 : ret;
