I evaluated a little more on this behavior and realized that actually many
many parts of our software will open a SHOWMODAL dialog to the response of
a message from the server, that is parsed with our protocol parser from
within the OnDataAvailable event of the socket, and this behavior
completely broken our software because now everytime it opens a form from
within the dataavailable event (indirectly), the socket will no longer
process any more messages while the form is open, and I guess that this is
wrong...

Since ICS is designed to be asynchronous it should not prevent me from
opening a form using showmodal as a response of a socket message...

Just to make clear, I'm using a PLAIN TCP socket without SSL

Well, researching a little more on the issue I found this:

procedure TCustomSslWSocket.Do_FD_READ(var Msg: TMessage);
var
    Len        : Integer; // How much to receive
    Buffer     : array [0..(SSL_BUFFER_SIZE * 2) -1] of AnsiChar;
    NumRead    : Integer;
    nError     : Integer;
    Res        : Integer;
    PBuf       : TWSocketData;
    Dummy      : Byte;
begin
 { V8.22 moved here from Do_SSL_FD_READ  }
    WSocket_Synchronized_WSAASyncSelect({$IFDEF POSIX}Self,{$ENDIF}
         FHSocket, Handle, FMsg_WM_ASYNCSELECT, FD_WRITE or FD_CLOSE or
FD_CONNECT);
    try
        if (not FSslEnable) or (FSocksState <> socksData) or
           (FHttpTunnelState <> htsData) then begin
            inherited Do_FD_READ(msg);
            Exit;
        end;



The problem seems to be with this first call from
CustomSslWSocket.Do_FD_READ:
    WSocket_Synchronized_WSAASyncSelect({$IFDEF POSIX}Self,{$ENDIF}
FHSocket, Handle, FMsg_WM_ASYNCSELECT, FD_WRITE or FD_CLOSE or FD_CONNECT);

If I just comment out this routine, then the problem is solved but I guess
that SSL will not work (I'm not using SSL at this moment anyway)

In my point of view, if I'm using a plain socket without SSL,
this TCustomSslWSocket class should NOT interfere with the operation of the
socket and should just call inherited Do_FD_READ in case SSL is not being
used instead of calling some socket routine...

Would someone please look into this issue? I can make some example
application to demonstrate the behavior (I just don't know how to properly
fix it)

Thanks



On Sat, Aug 13, 2016 at 2:50 PM, Éric Fleming Bonilha <e...@digifort.com.br>
wrote:

> Hi
>
> I recently came across an issue with our software after updating to ICS
> 8.26
>
> We previously used ICS 8.06 and its default compiling directives did not
> add SSL support, but 8.26 by default activates SSL and makes TWSocket class
> to be derived from SSL socket
>
> I don't know if the problem is related to the SSL socket derivation but
> probably yes since deactivating SSL will make socket behave like before,
> which makes me think that could be a bug because socket behavior should not
> change because I activated SSL (even though I don't use it now, our project
> will require it later)
>
> So, basically the issue is in a message loop processing I guess
>
> In our CLIENT application there is a code that opens a form using
> SHOWMODAL when it receives a message from the server (Client is connected
> to server using our own protocol). As you probably know, SHOWMODAL will
> create a windows message loop so application can keep processing windows
> messsages. The problem is that apparently when compiling with SSL, when I
> call a showmodal from my protocol parser (that is called from
> OnDataAvailable) basically making showmodal being indirectly called from
> within the event handler of socket OnDataAvailable, it will not process any
> more socket messages while my form is open, although the application keeps
> processing all other windows messages it looks like any socket message (at
> least data rcv messages) are no longer being processed and my socket gets
> "hang" while form called with SHOWMODAL is open.
>
> This behavior occurs only when activating SSL, but if I deactivate SLL
> support it will work just fine, and while my form is open with showmodal,
> the socket still keeps processing new messages (from within the message
> loop created by showmodal calling).
>
> I guess I know I should not indirectly block OnDataAvailable event handler
> by calling a showmodal because of show it works (creates a new message loop
> and things can get messy), but this works just fine without the USE_SSL
> define, so, I would like to understand why this happens.
>
> I could just disable USE_SSL for now, but I know I will soon need this is
> our future release and I just want to understand why this socket behavior
> changed and what should be the "correct" way of working with it
>
> Thanks
>
> Eric
>
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to