-
Content Count
1196 -
Joined
-
Last visited
-
Days Won
16
Everything posted by FPiette
-
Best type for data buffer: TBytes, RawByteString, String, AnsiString, ...
FPiette replied to Rollo62's topic in Algorithms, Data Structures and Class Design
So this is perfect for a linked list! The linked list will grow as the source data thread add more buffer at the end. Buffer extracted from released buffers after processing or new buffer if no free available. Processors, will take a buffer from the start of the linked list for processing and move the buffer to the released linked list. Then you have to have a linked list per source data. When a processor retrieve the first buffer from the linked list and determine it is not complete, then it is flagged and it stays in the linked list. When the next data chunk arrive, and the first buffer in the list is flagged as incomplete, then it is flagged as fragment so that the processors knows that if must also retrieve the next item in the list (or a few ones) to get complete data. btw: Linked list are frequently used to implement queues (FIFO, LIFO). I never seriously looked at how Delphi RTL implement TQueue<T> but I think it is an array which is less efficient. -
Best type for data buffer: TBytes, RawByteString, String, AnsiString, ...
FPiette replied to Rollo62's topic in Algorithms, Data Structures and Class Design
You'll get performance if you avoid copying data. If your receiver component accept a buffer (You said TBytes which is a TArray<Byte>), you can keep it into that buffer, add that buffer in a linked list of pointers to those TBytes buffer and pass another buffer for the next receive. Each "processor" will then receive the data it know how to handle right and produce some result maybe in the same buffer or in a new one. One a buffer is not needed, it is freed or better put on a second linked list with available buffers and reuse that buffer later. You'll avoid memory allocation/deallocation which produce memory fragmentation which is also very bad if the application has to run continuously. Resizing and array (Remember TBytes is an array) is an inefficient operation. It involve copying data because the array can't always be expanded in place and obviously it involves memory alloc/free because you use a dynamic array (TBytes). I don't know what your receiver looks like nor if the data size is known up front. But if possible, it is better to preallocate a buffer large enough for - let's say - 90% of the occurrences and reuse that buffer again and again (Because as I said above you have a linked list of free buffers). -
Best type for data buffer: TBytes, RawByteString, String, AnsiString, ...
FPiette replied to Rollo62's topic in Algorithms, Data Structures and Class Design
Linked list is among the fastest. Much faster than arrays or strings. But since you didn't told us how data is coming and which processing you need to do, all answers (Mine and from others) are just guess and probably not really helpful. You'll get performance if you minimize the number of data copy and memory allocation. Be aware of hidden data copy and allocation when you resize a dynamic array or a string and all variation. -
Best type for data buffer: TBytes, RawByteString, String, AnsiString, ...
FPiette replied to Rollo62's topic in Algorithms, Data Structures and Class Design
You forgot a data structure specifically designed to handle the processing of your data. For example linked list of some basic data type. Since we don't say anything about the details of your processing, I can't be more specific. -
OverbyteIcsLIBEAY.hpp Line 58 typedef void __cdecl (*TCryptoThreadIDCallback)(Overbyteicsssleay::PCRYPTO_THREADID ID);
FPiette replied to ICS_NEW's topic in General Help
Yes, this is what is required. No need to build one for Delphi since it already exists. -
Have a look at this answer on StackOverflow. It is about a TEdit, but IMO the same concept applies to a TComboBox.
-
Use a TTimer to change the color of the button periodically. If you need a lot of them, you can derive your own TFlashingButton class/component to have an easy to use flashing button on the tool palette.
-
Maybe this: https://www.virtual-serial-port.org
-
Localization inquery
FPiette replied to Clément's topic in Algorithms, Data Structures and Class Design
I use dxGetText (https://sourceforge.net/projects/dxgettext/) in all my application which must support several languages. To do the translation it self, I used PoEdit (https://poedit.net/). I have never been confronted to some parts being translated in one language and others translated in a different languages but I think it is possible to do it since translation process pass by functions you have control on it. -
I am using that solution with great success. 1) The main service launch a child process which does the work. 2) The main service is notified by Windows when his child exit (You can have a thread waiting for process termination). 3) The main service check child process health by sending a request using IPC. In my case the child service is accessed by clients so the main service use the same code to connect to the child process. If the connection fails, then the main service kill the child process. 4) When the child service gracefully terminate it set a flag so that the main service do not restart it but also close. The flag is actually a file created by the main service and deleted by the child process when terminating properly. If the main service detect the file is still there when the child process terminate, then the child process crashed.
-
Local string variable value is not assigned for 2nd and following calls
FPiette replied to ertank's topic in RTL and Delphi Object Pascal
For that kind of bug, a step by step execution using the debugger make it obvious! -
TWSocketClient.OnDataAvailable not firing off after a day or two
FPiette replied to aehimself's topic in Network, Cloud and Web
Even when you know the length of data supposed to be sent by the sender, it is important to read data as much as it comes in for the reason I explained in my previous messages. More data can come in because the sender queue requests without waiting for prior answer, or maybe the sender is simply trying to hang your application (DOS attack). -
Local string variable value is not assigned for 2nd and following calls
FPiette replied to ertank's topic in RTL and Delphi Object Pascal
I use madExcept for that purpose. Be sure to select "crash instantly on buffer overflow" (or underflow). -
TWSocketClient.OnDataAvailable not firing off after a day or two
FPiette replied to aehimself's topic in Network, Cloud and Web
One more warning: When using TCP, there is no packet at all, just a stream of bytes. What the receiver sees is totally independent of how the sender send data. The sender may call a single send and the receiver have two OnDataAvailable events and the sender may call several send but the receiver receive only one single OnDataAvailable event for all data. Writing a program using TCP assuming there is a correlation between sender's send() and receiver OnDataAvailable will sooner or later explode on your face! (Frecnh expression). -
TWSocketClient.OnDataAvailable not firing off after a day or two
FPiette replied to aehimself's topic in Network, Cloud and Web
Sure, but if data is not read, the program get stuck in that loop forever. That is why it is important to read all data and throw away what is not possible to keep, raising an exception or showing an error because throwing away data silently will make the program have unexpected results - for the less. -
Local string variable value is not assigned for 2nd and following calls
FPiette replied to ertank's topic in RTL and Delphi Object Pascal
var Request: string; begin Request := '{"appKey":"' + AppKey + '","secretKey":"' + SecretKey + '"}'; Request is a local variable and the way you initialize it is perfectly correct. Each time Login() is called, you get a new variable (on the stack) which is initialized. If this doesn't work, then there is something elsewhere corrupting memory. That will be difficult to find. Especially for us which have no view on your code. -
It is sometimes very useful when you have to port code from another language which makes use of that feature. It is not always easy to replace several variables in a single function having same name but totally independent.
-
TWSocketClient.OnDataAvailable not firing off after a day or two
FPiette replied to aehimself's topic in Network, Cloud and Web
One more important thing: In the OnDataAvailable event, you should read ALL data arriving. So you should make a loop calling Receive until it return < 0. If the buffer used for receive is to small, read anyway in a secondary small buffer and throw data away, then signal the error to the user "buffer to small". -
TWSocketClient.OnDataAvailable not firing off after a day or two
FPiette replied to aehimself's topic in Network, Cloud and Web
Do not rely on RcvdCount to know if data is ready to be read. In some case, winsock returns 0 even if more data is available. Just call Receive and use the return value. Call Receive again until Receive returns < 0. This is not an ICS issue but a known Winsock behaviour, that's why you experience the issue with both ICS and your old socket component. -
Try to write a very simple program to reproduce the error. For example a single form with two comboboxes and a button. Implement the logic you exposed in your question and in the button OnClick, just call ShowMessage. If it doesn't work, publish the code here. If it works, then double check you application to find whicg error you made.
-
Where is the Install command in the Project Manager of D10.3?
FPiette replied to Silver Black's topic in VCL
You are at the right place. A package can be either designtime or runtime or both. You select what you need. To get "install" in to project manager popup menu, a package must be "Designtime" or "Designtime and runtime". -
How to operate a private field in other unit?
FPiette replied to pcplayer99's topic in RTL and Delphi Object Pascal
Not sure I correctly understand what need and what you've done. I understood that you copied Delphi source code in another unit and then modified that unit to fit you needs. Then why not modify it further to make visible what you need ? btw: Modifying a Delphi unit although technically correct, will make your application difficult to maintain on the long term as Delphi source code will change: you'll have to apply your changes, if possible, to the new source and this may be difficult or even impossible. To avoid this problem, you probably have to change your design. -
TWClientSocket OnConnect & OnDisconnect handlers?
FPiette replied to aehimself's topic in ICS - Internet Component Suite
You should display the ErrCode argument in OnSessionConnected event handler. I'm sure it is something like 10061. If the connection is successful, then the ErrCode is zero. Same for OnSessionClosed. OnSessionClosed is immediately called when the connection fails. So what you see is normal behavior. -
TWClientSocket OnConnect & OnDisconnect handlers?
FPiette replied to aehimself's topic in ICS - Internet Component Suite
Maybe the server you connect to wait for some request. If nothing comes within a given time, then the server close the connection. In your code, you should add an OnDataAvailable handler to read incoming data and display it. Why not first try one of the client demos provided with ICS distribution? -
Where is the Install command in the Project Manager of D10.3?
FPiette replied to Silver Black's topic in VCL
You package must be flagged as "Design time page". See the package project options.