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 OnSendData() event?
> That seems/sounds like the more logical event to send data.

No you use OnSendData 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 OnDataSent (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.overbyte.be/eng/overbyte/teamics.html
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: TObject);
> 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 TfClientMain.SendMessageToRealTime(ARecipient: Integer;
> AMsgToSend: String);
> begin
>   if not (ICSSocket_Sending.State = wsConnected) then begin
>     ICSSocket_Sending.Addr := '127.0.0.1';
>     ICSSocket_Sending.Port := ClientDM.GetServerPortForClientToCall; 
>     ICSSocket_Sending.Connect;
>   end;
>   slMessagesToSend.Add(AMsgToSend);
> end;

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

> procedure TfClientMain.ICSSocket_SendingSessionConnected(Sender: TObject;
> 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(
>     SOCKET_EVENT, 'ICSSocket_SendingSessionConnected', 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 OnSessionConnected") }
>   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 OnSendData() event?
> That seems/sounds like the more logical event to send data.


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to