Dossy, It is irrelevant...
Absolutely irrelevant.. With int trigger[2] static void TriggerDriver(Driver *drvPtr) { if (send(drvPtr->trigger[1], "", 1, 0) != 1) { The send doesn't work and always returns error With SOCKET trigger[2]; It DOES Work... Back to your question: The program should be: #include <windows.h> #include <winsock.h> int main(int argc, char* argv[]) { printf("sizeof(SOCKET) = %d, sizeof(int) = %d\n", sizeof(SOCKET), sizeof(int)); return 0; } Its output when compiled as Windows 64 is: c:\Itmp>cl test.c Microsoft (R) C/C++ Optimizing Compiler Version 16.00.30319.01 for x64 Copyright (C) Microsoft Corporation. All rights reserved. test.c Microsoft (R) Incremental Linker Version 10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved. /out:test.exe test.obj c:\Itmp>test sizeof(SOCKET) = 8, sizeof(int) = 4 and when compiled with Windows 32 C:\Itmp>cl test.c Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. test.c Microsoft (R) Incremental Linker Version 10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved. /out:test.exe test.obj C:\Itmp>test sizeof(SOCKET) = 4, sizeof(int) = 4 C:\Itmp> I hope you understand my point now (thank you for your educational example which just proves it.) NOW BACK TO US 1. The Aolserver code base inconsistently uses int and SOCKET when declaring /defining variables to be used as Sockets. 2. This inconsistency it is not a Windows/Unix problem - it is just a plain inconsistency 3. We are just lucky that Windows 64 exposed the problem. 4. I do recommend that one of the code maintainers takes a walk on code base and makes all the sockets declarations/definitions consistent. Thank you, Maurizio From: AOLserver Discussion [mailto:AOLSERVER@LISTSERV.AOL.COM] On Behalf Of Dossy Shiobara Sent: 04 August 2011 16:56 To: AOLSERVER@LISTSERV.AOL.COM Subject: Re: [AOLSERVER] Aolserver Progress - Some few examples.... On Win64, can you tell me what sizeof(SOCKET) and sizeof(int) are? Try this simple program: ---- #include <windows.h> #include <winsock2.h> int main(int argc, char[] *argv) { printf("sizeof(SOCKET) = %d, sizeof(int) = %d\n", sizeof(SOCKET), sizeof(int)); return 0; } ---- I just learned that on Win64, Microsoft *changed* the definition of SOCKET from u_int to UINT_PTR: /* * The new type to be used in all * instances which refer to sockets. */ #ifdef _WIN64 typedef UINT_PTR SOCKET; #else typedef u_int SOCKET; #endif Which means 64-bit SOCKET on Win64 vs. 32-bit SOCKET on Win32 or most Unix-like systems. ... The short answer is, yes, anywhere we have a variable that contains a handle to a socket, we should use the SOCKET type, not a naked "int" declaration, for portability. On 8/4/11 10:28 AM, Maurizio Martignano wrote: It is not a matter of understanding It is a matter of testing On Windows 64 int trigger[2] doesn't work whereas SOCKET trigger[2] does work. On top of that in several other places SOCKET has been used, so if for no other reason, I suggest one of the code maintainers takes a proper walk on the code base and make sure that all sockets are SOCKET sockets and not int sockets. -- Dossy Shiobara | "He realized the fastest way to change do...@panoptic.com | is to laugh at your own folly -- then you http://panoptic.com/ | can let go and quickly move on." (p. 70) * WordPress * jQuery * MySQL * Security * Business Continuity * -- AOLserver - http://www.aolserver.com/ To Remove yourself from this list, simply send an email to <lists...@listserv.aol.com> with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank. -- AOLserver - http://www.aolserver.com/ To Remove yourself from this list, simply send an email to <lists...@listserv.aol.com> with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.