Subject: Re: libssh2 master 1b3b7b2... Add test to check if the socket is connected.

Re: libssh2 master 1b3b7b2... Add test to check if the socket is connected.

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 24 Dec 2009 11:00:31 +0100 (CET)

On Thu, 24 Dec 2009, libssh2_at_git.stuge.se wrote:

> +++ b/src/agent.c
> @@ -128,7 +128,7 @@ struct _LIBSSH2_AGENT
> {
> LIBSSH2_SESSION *session; /* the session this "belongs to" */
>
> - int fd;
> + int fd; /* -1 when not connected */

Hey,

Note that internally in libssh2 we use libssh2_socket_t and not 'int' for
sockets so that they work better on more operating systems (like windows).

Similarly, we need a defien for "invalid sockt" as -1 is not nice to store
there unconditionally for libssh2_socket_t. I suggest something like:

--- a/src/libssh2_priv.h
+++ b/src/libssh2_priv.h
@@ -151,8 +151,10 @@ static inline int writev(int sock, struct iovec *iov, int
n

  #ifdef WIN32
  typedef SOCKET libssh2_socket_t;
+#define SOCKET_BAD ~0
  #else /* !WIN32 */
  typedef int libssh2_socket_t;
+#define SOCKET_BAD -1
  #endif /* WIN32 */

  /* RFC4253 section 6.1 Maximum Packet Length says:

-- 
  / daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2009-12-24