This fix is not OK. FHSocket may be negative. It has to be cast to WParam.
See other messages.
-- 
francois.pie...@overbyte.be
Embarcadero MVP
http://www.overbyte.be
http://francois-piette.blogspot.com





-----Message d'origine-----
De : TWSocket [mailto:twsocket-boun...@lists.elists.org] De la part de
Michael Gasser
Envoyé : mardi 24 décembre 2013 12:06
À : twsocket@lists.elists.org
Objet : Re: [twsocket] TWSocket Digest, Vol 550, Issue 2



Hi pde...@gmail.com

I still think there is a little bug in OverbyteIcsWSocket.pas (most recent
version 8.06 of OverbyteIcsWSocket.pas [ISC v7 was OK]) wihich causes this
problem in function TCustomWSocket.Send(Data : TWSocketData; Len : Integer)
: Integer; at line PostMessage(Handle, FMsg_WM_ASYNCSELECT, FHSocket,
IcsMakeLong(FD_WRITE, 0));

[described in my posts 7.11. 12.11.2013]

In some cases the values of FHSocket, FState are FHSocket <>1 and FState =
wsConneced WHILE ENTERING the function TCustomWSocket.Send - BUT their
values change to -1, wsClosed in TryToSend;  [socket not connected]

If these values change to -1, wsClosed (in TryToSend; ) the error you
describe occurs.


To get rid of the error you mention:

1. Open OverbyteIcsWSocket.pas
2. In  OverbyteIcsWSocket.pas search for TCustomWSocket.Send.

Code "as is":
    if bAllSent then begin
        { We post a message to fire the FD_WRITE message which in turn will}
        ...
        { the send function.                                               }
        PostMessage(Handle,
                    FMsg_WM_ASYNCSELECT,
                    FHSocket,
                    IcsMakeLong(FD_WRITE, 0));
    end;

Add the line "if FHSocket > 0" :

    if bAllSent then begin
        { We post a message to fire the FD_WRITE message which in turn will}
        ...
        { the send function.                                               }
        if FHSocket > 0 then  // add this line...
        PostMessage(Handle,
                    FMsg_WM_ASYNCSELECT,
                    FHSocket,
                    IcsMakeLong(FD_WRITE, 0));
    end;


This fixes your problem.

or even better:
Go to the procedure TryToSend; and set the variable bAllSent to false 
whenever an error like #10057 occurrs. This fixes the problem too.


Regards
Michael




> Message: 1
> Date: Sat, 21 Dec 2013 15:06:45 +0200
> From: ????? ??????? <pde...@gmail.com>
> To: "twsocket@lists.elists.org" <twsocket@lists.elists.org>
> Subject: [twsocket] Errors while send, if client disconnected from
> socket
> Message-ID:
> <CA+70vSCkD396D+CbzGpCzxWFhPNX68VktK9byvTwQw6fuF=j...@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hello
>
> Sometimes client can disconnect on multithreaded server while send, after
> that I receive
> "Range check error" or
> "Socket is not connected (#10057 in Send)"
>
> How can I avoid these errors?
> I'm checking client state before send.
> Must I ignore both these errors? If yes, I can understand to ignore
> "#10057", but why shuld I ignore "range check error".
> It is very rarely error (one time on 1.000.000 send), but it happens every
> day on my server.
>
> //TTCPClient = class(TsslWSocketTHrdClient)
>
>  if (FTcpClient as TTCPClient).state = wsConnected then
>        try
>          (ftcpclient as TTCPClient).Send(data, 4);
> // here error (in debug I see that client disconnected after entering in
> function Send
>        except
>          on e: exception do
>            log.debug('Error in sendstr TClient.writelnuncompressed:' +
> e.Message);
>        end;
>
>
> Thank you.
>
>
> 

-- 
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

-- 
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