Windows

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Messages being sent, but Client app locking up

    6 answers - 2525 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    I am successfully sending messages from my Client MIDAS app to my Server
    MIDAS app, but then the Client app locks up.
    Here is my code:
    1) The user (me) presses a button to send a message:
    { This is a test }
    procedure TfClientMain.Button1Click(Sender: T);
    begin
    SendMessageToRealTime(1, Format('%s sent at %s', [edtTestMessage.Text,
    DateTimeToStr(Now)]));
    end;
    2) This calls a method which makes a connection, if necessary, then adds the
    message to a string list. ICSSocket_Sending is a TWSocket component:
    procedure (ARecipient: Integer;
    AMsgToSend: String);
    begin
    if not (ICSSocket_Sending.State = wsConnected) then begin
    ICSSocket_Sending.Addr := '127.0.0.1';
    ICSSocket_Sending.Port := ;
    ICSSocket_Sending.Connect;
    end;
    slMessagesToSend.Add(AMsgToSend);
    end;
    3) I then actually send the data in the SessionConnected() event:
    procedure (Sender: T;
    ErrCode: Word);
    var
    i: Integer;
    begin
    if ErrCode <0 then begin
    ClientDM.InsertException(CurrentUser, IntToStr(ErrCode),
    SocksErrorCodeToStr(Error));
    Exit;
    end;
    if slMessagesToSend.Count = 0 then
    Exit;
    ClientDM.InsertEventLog(
    SCKET_EVENT, '', Now, CurrentUser,
    GetMachineName);
    { According to Arno Garrels of TeamICS on the ICS Mailing List, the
    sending
    should be done here ("Send your first bytes from SessionConnected") }
    for i := 0 to Pred(slMessagesToSend.Count) do
    ICS_SendString(slMessagesToSend[i]);
    { Now get rid of them so they're not sent again }
    for i := Pred(slMessagesToSend.Count) downto 0 do
    slMessagesToSend.Delete(i);
    end;
    The message is getting sent (received by the Server app), but then the
    Client app locks up. Why would this be?
    And also: Why wouldn't the sending of the data be in the SendData() event?
    That seems/sounds like the more logical event to send data.
    The information transmitted is intended only for the person or entity to
    which it is addressed and may contain confidential and/or privileged
    material. If the reader of this message is not the intended recipient,
    you are hereby notified that your access is unauthorized, and any review,
    dissemination, distribution or copying of this message including any
    attachments is strictly prohibited. If you are not the intended
    recipient, please contact the sender and delete the material from any
    computer.
  • No.1 | | 927 bytes | |

    , I left out a part:

    { Called by SendMessageToRealTime() }
    procedure TfClientMain.ICS_SendString(AMessageToSend: String);
    begin
    try
    ICSSocket_Sending.SendStr(AMessageToSend);
    except
    on E: Exception do begin
    ShowMessage(Format('%s: %s', [E.ClassName, E.Message]));
    ClientDM.InsertException(CurrentUser, E.Message, E.ClassName);
    end;
    end;
    end;

    The information transmitted is intended only for the person or entity to
    which it is addressed and may contain confidential and/or privileged
    material. If the reader of this message is not the intended recipient,
    you are hereby notified that your access is unauthorized, and any review,
    dissemination, distribution or copying of this message including any
    attachments is strictly prohibited. If you are not the intended
    recipient, please contact the sender and delete the material from any
    computer.
  • No.2 | | 728 bytes | |

    Adding ICSSocket_Sending.Close as shown below solves the lockup problem:

    for i := Pred(slMessagesToSend.Count) downto 0 do
    slMessagesToSend.Delete(i);
    ICSSocket_Sending.Close; //Voila!

    The information transmitted is intended only for the person or entity to
    which it is addressed and may contain confidential and/or privileged
    material. If the reader of this message is not the intended recipient,
    you are hereby notified that your access is unauthorized, and any review,
    dissemination, distribution or copying of this message including any
    attachments is strictly prohibited. If you are not the intended
    recipient, please contact the sender and delete the material from any
    computer.
  • No.3 | | 2929 bytes | |

    Hello Clay,

    The message is getting sent (received by the Server app), but then the
    Client app locks up. Why would this be?

    What exacly mean by 'locks up' ? Is the application not receiving
    windows messages anymore (eg mouse clicks and so), or something else ?

    And also: Why wouldn't the sending of the data be in the SendData() event?
    That seems/sounds like the more logical event to send data.

    No you use SendData if you wants for example use a progress bar or
    other purpose. It is fired when winsock is feeded with the next chunck
    of data. You also have DataSent (dont confuse it) which is fired when
    TWSocket has delivered his data to winsock. This is the place to send
    next chunck of data if you have a lot to send and dont want to overload
    memory and CPU.

    Rgds, Wilfried [TeamICS]

    http://www.mestdagh.biz

    Thursday, March 29, 2007, 22:05, Clay Shannon wrote:

    I am successfully sending messages from my Client MIDAS app to my Server
    MIDAS app, but then the Client app locks up.

    Here is my code:

    1) The user (me) presses a button to send a message:

    { This is a test }
    procedure TfClientMain.Button1Click(Sender: T);
    begin
    SendMessageToRealTime(1, Format('%s sent at %s', [edtTestMessage.Text,
    DateTimeToStr(Now)]));
    end;

    2) This calls a method which makes a connection, if necessary, then adds the
    message to a string list. ICSSocket_Sending is a TWSocket component:

    procedure (ARecipient: Integer;
    AMsgToSend: String);
    begin
    if not (ICSSocket_Sending.State = wsConnected) then begin
    ICSSocket_Sending.Addr := '127.0.0.1';
    ICSSocket_Sending.Port := ;
    ICSSocket_Sending.Connect;
    end;
    slMessagesToSend.Add(AMsgToSend);
    end;

    3) I then actually send the data in the SessionConnected() event:

    procedure (Sender: T;
    ErrCode: Word);
    var
    i: Integer;
    begin
    if ErrCode <0 then begin
    ClientDM.InsertException(CurrentUser, IntToStr(ErrCode),
    SocksErrorCodeToStr(Error));
    Exit;
    end;

    if slMessagesToSend.Count = 0 then
    Exit;

    ClientDM.InsertEventLog(
    SCKET_EVENT, '', Now, CurrentUser,
    GetMachineName);
    { According to Arno Garrels of TeamICS on the ICS Mailing List, the
    sending
    should be done here ("Send your first bytes from SessionConnected") }
    for i := 0 to Pred(slMessagesToSend.Count) do
    ICS_SendString(slMessagesToSend[i]);
    { Now get rid of them so they're not sent again }
    for i := Pred(slMessagesToSend.Count) downto 0 do
    slMessagesToSend.Delete(i);
    end;

    The message is getting sent (received by the Server app), but then the
    Client app locks up. Why would this be?

    And also: Why wouldn't the sending of the data be in the SendData() event?
    That seems/sounds like the more logical event to send data.
  • No.4 | | 845 bytes | |

    <<What exacly mean by 'locks up' ? Is the application not receiving windows
    messages anymore (eg mouse clicks and so), or something else ? >>

    The app became totally unresponsive. As mentioned in an earlier post, I
    think, though, I fixed it by calling TWSocket's Close() method.

    The information transmitted is intended only for the person or entity to
    which it is addressed and may contain confidential and/or privileged
    material. If the reader of this message is not the intended recipient,
    you are hereby notified that your access is unauthorized, and any review,
    dissemination, distribution or copying of this message including any
    attachments is strictly prohibited. If you are not the intended
    recipient, please contact the sender and delete the material from any
    computer.
  • No.5 | | 318 bytes | |

    Hello Clay,

    The app became totally unresponsive. As mentioned in an earlier post, I
    think, though, I fixed it by calling TWSocket's Close() method.

    You you have an DataAvailable handler and if yes, do you receive
    always all data ?

    Rgds, Wilfried [TeamICS]

    http://www.mestdagh.biz
  • No.6 | | 764 bytes | |

    <<You you have an DataAvailable handler>>

    Yes

    << and if yes, do you receive always all data ?>>>

    I think so

    Message
    From: twsocket-bounces (AT) elists (DOT) org [mailto:twsocket-bounces (AT) elists (DOT) org]
    Behalf Wilfried Mestdagh
    Sent: Saturday, March 31, 2007 2:30 AM
    To: ICS support mailing
    Subject: Re: [twsocket] Messages being sent, but Client app locking up

    Hello Clay,

    The app became totally unresponsive. As mentioned in an earlier post,
    I think, though, I fixed it by calling TWSocket's Close() method.

    You you have an DataAvailable handler and if yes, do you receive always
    all data ?

    Rgds, Wilfried [TeamICS]

    http://www.mestdagh.biz

Re: Messages being sent, but Client app locking up


max 4000 letters.
Your nickname that display:
In order to stop the spam: 4 + 4 =
QUESTION ON "Windows"

EMSDN.COM