bug-commoncpp
[Top][All Lists]
Advanced

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

Re: Think there is a problem in ost::Socket::setCompletion


From: David Sugar
Subject: Re: Think there is a problem in ost::Socket::setCompletion
Date: Thu, 29 Jul 2004 10:03:06 -0400
User-agent: Mozilla Thunderbird 0.7.1 (Macintosh/20040626)

Looking at 1.2.4, it appears something like this change had already been implemented...

Michael Uman wrote:

Hello,

I think I just fixed a bug in Socket::setCompletion.

Here is what has happened... I have an application which uses wxWindows
and CommonCpp. It works fine on both Windows and Linux when run
natively. But I decided to try to run the Windows executable using the
WINE emulator. Now the Wine debugger complained about a problem. I built
everything for debug, and used the .pdb's generated. Now when wine hit
the problem , the stack trace indicated it was in the ioctlsocket
function, called from setCompletion. I looked into the source code and
noticed that the call doesn't conform to the Windows Platform SDK
description of the function. According to the docs the prototype of
ioctlsocket is:

int ioctlsocket(
 SOCKET s,
 long cmd,
 u_long* argp
);

This indicates that the 3rd argument is a pointer to an u_long {unsigned
long int}. It appears in the socket.cpp module that the integer 0 or 1
is passed in the argument. The SDK describes the FIONBIO ioctl using the
following language:

FIONBIO
The argp parameter is a pointer to an unsigned long value<<. Set argp
to a nonzero value if the nonblocking mode should be enabled, or zero if
the nonblocking mode should be disabled. When a socket is created, it
operates in blocking mode by default (nonblocking mode is disabled). This is consistent with BSD sockets. argp value Nonblocking mode 0 Disabled nonzero Enabled
I modified the source and rebuilt the ccgnu2.dll {actually the
ccgnu2d.dll} and retried my tests. Now everything works well. I am still
having another problem concerning commoncpp ost::Socket::error when it
comes to throwing an exception. But this error only occurs when my app
is unable to attach to the server {workable but still not acceptable}.

My patch is attached to this email... basically just pass the ulong
which is set according to the immediate flag {you'll see...}...

I hope this is helpful. Also, thank you for maintaining such a useful
cross-platform function library... ;)

Thank you,
Michael A. Uman
Sr. Software Engineer, System tools
Sigma Designs


------------------------------------------------------------------------

--- socket.cpp  2003-06-06 16:16:46.000000000 -0700
+++ /users/muman/socket.cpp     2004-07-28 13:43:47.000000000 -0700
@@ -687,17 +687,12 @@
        flags.completion = immediate;
#ifdef WIN32
        // note that this will not work on some versions of Windows for 
Workgroups. Tough. -- jfc
-       switch( immediate )
-       {
-       case false:
-               // this will not work if you are using WSAAsyncSelect or 
WSAEventSelect.
-               // -- perhaps I should throw an exception
-               ioctlsocket( so, FIONBIO, (unsigned long *) 1);
-               break;
-       case true:
-               ioctlsocket( so, FIONBIO, (unsigned long *) 0);
-               break;
-       }
+
+       u_long  argp;
+
+       argp = (immediate == false)?1:0;
+       ioctlsocket( so, FIONBIO, (unsigned long *) &argp);
+
#else
        int fflags = fcntl(so, F_GETFL);

------------------------------------------------------------------------

_______________________________________________
Bug-commoncpp mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/bug-commoncpp




reply via email to

[Prev in Thread] Current Thread [Next in Thread]