[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Patch] Windows sockets version 2.2


Aris,

".. Applications on these platforms should normally request Winsock 2.2"
is copied from MSDN.
For sure there is a reason why there is a version 2.2 released. I can't accept a
general noob from you. Question: Is this change harmful or introduce a regression?
If the patch for 2.2 triggers regression, drop it.

I come across with problems using libssh - (other thread point to point failed)
the friends testing in the field now winscp which works out of the box at the p2p environment. So I make a quick fix set the 2.0 with 2.2 but it turns out
not fix the problem.


Cheers
Chris




On Thursday, June 08, 2017 12:39 AM, Aris Adamantiadis wrote:
Hi Chris,

Total noob here. Does winsock 2.2 change some semantics/fix some bugs
from 2.0 we were used to see on windows? I'm thinking about WSAPoll that
we had to stop supporting because it was so buggy.

I don't understand this comment: +    /* Validate version it can
fallback to 2.0 */
If winsock 2.2 works on everything above 95, we don't really need a
fallback anyway. I doubt libssh would run on 98 anyway.

Aris

On 7/06/17 07:37, Chris Ruehl wrote:
Window Sockets 2.2 is the recommended DLL version, this patch
change from v2.0 to v2.2 and add fallback check.

Windows Sockets version 2.2 is supported on Windows Server 2008,
Windows Vista, Windows Server 2003, Windows XP, Windows 2000, Windows
NT 4.0 with Service Pack 4 (SP4) and later, Windows Me, Windows 98,
and Windows 95 OSR2. Windows Sockets version 2.2 is also supported on
Windows 95 with the Windows Socket 2 Update. Applications on these
platforms should normally request Winsock 2.2 by setting the
wVersionRequested parameter accordingly.


diff --git a/src/socket.c b/src/socket.c
index 022c9a76..372b669a 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -107,10 +107,15 @@ int ssh_socket_init(void) {
     struct WSAData wsaData;

     /* Initiates use of the Winsock DLL by a process. */
-    if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) {
+    /* Winsock v2.2 */
+    if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
+      return -1;
+    }
+    /* Validate version it can fallback to 2.0 */
+    if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) !=
2) {
+      WSACleanup();
       return -1;
     }
-
 #endif
     ssh_poll_init();






--
GTSYS Limited RFID Technology
9/F, Unit E, R07, Kwai Shing Industrial Building Phase 2,
42-46 Tai Lin Pai Road, Kwai Chung, N.T., Hong Kong
Tel (852) 9079 9521

Disclaimer: http://www.gtsys.com.hk/email/classified.html

References:
[Patch] Windows sockets version 2.2Chris Ruehl <chris.ruehl@xxxxxxxxxxxx>
Re: [Patch] Windows sockets version 2.2Aris Adamantiadis <aris@xxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org