Subject: Re: [libssh2] #163: use libssh2_socket_t for socket type

Re: [libssh2] #163: use libssh2_socket_t for socket type

From: libssh2 Trac <trac_at_libssh2.stuge.se>
Date: Thu, 04 Mar 2010 00:57:21 -0000

#163: use libssh2_socket_t for socket type
--------------------+-------------------------------------------------------
 Reporter: sldr | Owner: bagder
     Type: defect | Status: assigned
 Priority: normal | Milestone:
Component: API | Version: 1.2.4
 Keywords: | Blocking:
Blockedby: |
--------------------+-------------------------------------------------------

Comment(by sldr):

 What if the following (or something like it) was put in libssh2.h near
 top:

 #ifdef WIN32
 typedef SOCKET libssh2_socket_t;
 #else /* !WIN32 */
 typedef int libssh2_socket_t;
 #define INVALID_SOCKET -1
 #endif /* WIN32 */

 Change libssh2_session_startup to:
 LIBSSH2_API int libssh2_session_startup(LIBSSH2_SESSION *session,
 libssh2_socket_t sock)

 Also change the struct _LIBSSH2_POLLFD to:
 typedef struct _LIBSSH2_POLLFD {
     unsigned char type; /* LIBSSH2_POLLFD_* below */

     union {
         libssh2_socket_t socket; /* File descriptors -- examined with
 system select() call */

 The only problems I see are:
 1.
 If non-windows platforms define WIN32 for some reason but I don't thing
 this is a issue.
 2.
 On windows you will need to include WinSock2.h (or windows.h, etc.) so
 that SOCKET is defined or define it manually before libssh2.h is included.
 I think any code using the libssh2.h include file is going to need to do
 some type of include to get a socket type defined anyway on Windows
 platforms. The use of SOCKET also means that libssh2 has a better chance
 of working on a 64bit compile on Windows (I know that LOTS of other things
 would need to be checked too).

 Thanks for your time and consideration,
 SLDR
 (Stephen L. De Rudder)

-- 
Ticket URL: <http://libssh2.stuge.se/ticket/163#comment:3>
libssh2 <http://libssh2.stuge.se/>
C library for writing portable SSH2 clients
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-03-04