Skip to content

How to receive data multiple times in a single routine ?  #7

Description

@FrankBKK

Hi,

I have a problem when I want to download more than one time in a single routine - how do I know when the transfer is completed and I can send another command to receive a different set of data ?
see below rough example - that does not work

OnMouseClick: 
   if DataPortTCP.Active then DataPortTCP.Close();
   DataPortTCP.RemoteHost:= edApcUpsDServer.Caption;
   DataPortTCP.RemotePort:= IntToStr(seApcUpsDPort.Value);
   DataPortTCP.Active := True ;
   DataPortTCP.Open();

   DataPortTCP.RemoteHost:= edApcUpsDServer.Caption;
   DataPortTCP.RemotePort:= IntToStr(seApcUpsDPort.Value);
   DataPortTCP.Active := True ;
   DataPortTCP.Open();

   // do something with the received data from command A and command B 
end ;
OnDataPortOpen: 
   if rbStatus.Checked then
       DataPortTCP.Push(#00+#06+'status');  // send msg.length + msg: 'events' ;
   else if rbEvents.Checked then
      DataPortTCP.Push(#00+#06+'events');  // send msg.length + msg: 'events' ;
end ; 
OnDataPortDataAppear: 
   gsRawData := gsRawData + DataPortTCP.Pull() ;

   // When receive a #00#00 the transmission is completed
   if Pos(#00#00, gsRawData) > 0 then  DataPortTCP.Close();
end ;
OnDataPortClose: 
   DataPortTCP.Active := False ;
   if rbStatus.Checked then
       gsRawStatus := gsRawData ; 
   else if rbEvents.Checked then
       gsRawEvents := gsRawData ; 
end ; 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions