Jump to content

Kas Ob.

Members
  • Content Count

    464
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by Kas Ob.

  1. Right. Microsoft define its literals strictly in most cases, yet the compiler has well defined behavior, both for the best outcome from using the SDK. Look at this no problem and no warning. Here the compiler warns but compile, and the IDE didn't show anything different for the other DWORD and INT32 But here with lets say HANDLE Things are very different, as HANDLE are defined as struct as you know, specially to prevent the code from doing constant assignment. Like this Now why it is an integer: i think because it had been misunderstood as very big value (not the biggest though 0x80000000) instead of lowest possible negative value in 32bit, it could simply been declared as -1 and called a day, but who knows might be some legacy issue.
  2. Sorry, I can't agree on the rightness of this, heck.. i might call it rightmess ! Is Delphi 12 compiler handling (and generating machine code for) untyped numerical constant (literal) to be evaluated at runtime ? That is wrong. It would be great if you or anyone shared these warnings, i only can imagine what could be the case(s), but still when and where the compiler draw the line for such runtime evaluations yet it does accept them at compile time ? Also on side note how the compiler will handle such constants without a type when used in 64bit (Int64 and UInt64) ? See, the idea of being typed by a modifier after the "=" for numerical constant is disturbing me.
  3. assuming these cores doing near nothing except your stress test, right ? If you tried to open FireFox while doing such stress test looking for weak and missed situations to break, open it then try few tabs with Youtube playing videos, then see how that probability goes 100 times to 1/350, cores here will not help you as different application running on that server can easily make OS thread scheduler switch in different and biased way, this is the same case if you have your application running on server and then some like 2 Hyper-V guests booted on that device, it is doesn't worth to gamble. The role is one gamble like this and literally your application needs to restart at best case scenario, while the worst it will cost money like lost hours of work or simply corrupted data.
  4. This inconsistency is very annoying with Delphi compiler, and as you see it, untyped constant should be ... well .... untyped , duh ! , its value i mean in this case numerical value used as needed and casted in place of usage. In this piece the compiler refuse to handle "HandleDWORD(A)" for no logical reason, notice it doesn't have problem with the more dangerous one "HandleInteger(B)" const A = Integer($80000000); B = DWORD($80000000); C = $80000000; D = MINLONG; procedure HandleInteger(Value:Integer); begin Writeln(Value); end; procedure HandleDWORD(Value:DWORD); begin Writeln(Value); end; begin HandleInteger(A); HandleInteger(B); HandleInteger(C); HandleInteger(D); //HandleDWORD(A); // [dcc32 Error] Project5.dpr(36): E1012 Constant expression violates subrange bounds HandleDWORD(B); HandleDWORD(C); HandleDWORD(D); Readln; end. Result on my XE8 I wonder what is the result with Delphi 12 ?! considering there is a change did broke untyped constant handling.
  5. You lost me there, i don't understand the context of this assumption the why and for what, also sockets are sequential when they are TCP (and only) . About the mentioned error in the called Gitter (first time i see it), it is clear and without doubt that your receiver (client or server you didn't mention or i just miss it) had received unprocessed data by SSL/TLS handler, the other party sent plain data instead of the layered or secured TLS buffer. With this in mind then your server/client had messed up the integrity of the data (or stream), this easily can be happen if you are using multithreaded design and mixing protocol or multithreaded with corrupted (not protected or thread safe) socket list, example a buffer of plain data should first processed for layered security, then that buffer should be sent to the one and only socket established the secure connection or establishing one, here no matter if you switch between ICS or Indy the problem will persist, because your socket handling by your threading model is broken or faulty ! So as suggested above, provide the smallest but detailed (preferably code) how you handle threads and sockets and how are you separating them. Also expanding on this will help, Your own implemented data ACK or the the default TCP ACK ? Also as Francois mentioned to not complicate this thread with ICS and Indy, you might need to start another thread.
  6. Kas Ob.

    Assign socket to HttpCli

    Hi, Angus answered, but i want to suggest different and shorter approach. Just build an application with two servers HTTP at port 80 and HTTPS at port 443, make it relay everything from one connection to the other, that should solve your need for browsers secure connection to the device. By relay i mean, there should be one connection for each of these servers and whenever data being received from one then send it to the other one.
  7. I prefer long pants.
  8. Kas Ob.

    Surprising behavior of .ToUpper

    Hi, I always test my text and DB applications for international clients, not only international but when ever a user might be input text and locale might be a concern, which is almost always the case, with https://github.com/xupefei/Locale-Emulator Get familiar with that emulator mainly because it really save your time on changing OS settings (non-Unicode and interface) and combine that with virtual keyboard or just use copied text from Google Translate using Chrome and FireFox, don't use Edge ! Never used TStringHelper though in my code, mostly due the old Delphi versions, so try to reproduce this on your developing machine. Hope that help.
  9. Forgot the moral of all that The best way for high performance is to not push the threads (job or whatever), let them pull/poll on their own time. By centralizing the email handling with watcher in intervals, you will be removing huge bottleneck in case there is many emails, while the dispatchers will be almost a sleep sending and using SMTP because it is slow, so yes you can have 64 dispatcher at the same time and will not notice the CPU usage goes above %1, while the watcher can read hundreds in one go and also this is very short and fast process.
  10. Hi, Of course it is possible. You asked about threads and Remy gave a perfect answer to your question. Now let put my thoughts here: 1) Now you are thinking right and want to do the right thing, i mean eliminate the failing point or at least minimize and if possibly implement a recovery. 2) In my opinion best threads are threads that doesn't talk to each other. 3) You have Sqlite as storage and can serve as central coordinator or a hub while serving its propose to store data/task. What i suggest is to redesign you process a little differently, 1) Lets say you generated an email ( being to recover/restore/reset password or an invoice ...), this generated in a thread (any thread), then it will be pushed into a table in Sqlite, here comes the table itself with few extra columns, dtGenerated : will holds datatime of generation. dtSent : will hold the time it being picked to send ! intSend : the count of send tries. dtDelivered : hold the time when the email being delivered, and here when the SMTP finished receiving the email, we will consider this a success, enStatus : hold the status, Error, Failed, Pending , Delivered.... not so crucial but nice to have You can also put a an extra field to confirm the result of the sending from the SMTP, but this is an extra. Now one thread generate an email, and push it to the DB, there is another (one thread) its job to perform a query for emails in the DB with no dtSent value !, or with pending or ... the way you comfortable with. After grabbing these emails it will dispatch them to another one or more threads to perform the real SMTP sending, mean while and before dispatching them to these workers, that watcher threads will insert an ID of that email into special table called (lets say tbWorking) where that ID is key hence it is impossible to insert it twice, in Sqlite you can replace ID with simple ROWID from the email table, this is unique value, (also notice all DB servers has something similar like in Sqlite RowID is an Integer but in MYSQL it is hex or short string and there is ROWNUM i think..) If an email being sent successfully or not, then and only then the email table can be updated accordingly, and a delete should be issued to tbWorking, this tbWorking will server as lock free list that persist in case of catastrophic failure, like app crash or power cut, Threads will have a small and focused task to do, not generating emails, then store, them then, send them, then store the result... that is way too much work and it is also slow and will take time maximizing the risk of losing an email due to some other failure or Internet lose .... Anyway, what i wrote above is not a full solution that will fit you, most likely you will need to address the main point, what could happen and how to recover from each and every step and moment ? You need to think out side the box of generate-store-send-update and linear processing. I had done a project that similar to what you you need, but it was using MySQL and worked without a problem, With MySQL ?, the emails can be generated from completely different server running php and pushed to the MySQL, my server no matter if itself generated the email or from the web server remotely being added could and can send them all. Also don't forget to store logs for these operation, the logging the faster and more secure your process will be, i used two logging method with that, one on files and the other was in table in the DB, recoding the failures and successes. ps the watcher thread has one job to check for newly added or the emails not in tbWorking, it has low interval like 5-10 second, and will assume nothing on it first run, so it will/must update tbWorking on start, because filled value in that table on start means there is a conflict in need to be address, and the best way is to resend unless these are times email like resetting password then drop them. Hope that helps and give you insight.
  11. Kas Ob.

    GetIt alternatives

    @Vincent Parrett That is really fucking neat ! the more i look the more brilliant details a see ! It is a master piece done by a master. joking part : (hoping it is funny!) are you telling me this DPM is written in Delphi by Delphi developer in less than a decade ! @Sherlock there is another way 😎 https://medium.com/@peternjuguna76/hosting-a-json-file-on-github-pages-a-step-by-step-guide-52105a5a393a
  12. Kas Ob.

    GetIt alternatives

    Thank you, that is awesome !
  13. I can't find many resources about USER_MAPPED_FILE, in fact there is near nothing on the internet , found this https://stackoverflow.com/questions/41844842/when-error-1224-error-user-mapped-file-occurs though not so helpful. Anyway, to decode this situation using my own logic, the file is already being opened for mapping by another process, hence the BDS call to CreateFile is failing, and there is a few ways to catch the culprit redhanded. we start with the easiest way to find the culprit : 1) grab Handle from https://learn.microsoft.com/en-us/sysinternals/downloads/handle 2) put it some write permitted folder ( don't use any root directory like C: \ or D:\ ...) 3) run cmd with Administrator rights (elevated) on that folder 4) run this command : handle64 > hlist.txt 5) open that hlist.txt file and search for your EXE name Now if we fortunate and things went as we wish for, then we expect to see is something like this, here the file i locked with mapping is 1.txt Share with us to further discussion if discussion is needed, but in all cases we appreciate your finding ! Newer and updated guessing part: 1) system protection for some reason has kicked in . 2) that folder or driver is shared and/or locked by some GoogleDrive (may be) or something similar, and remotely there is software is parsing or handling that file, it easily can be an AV on remote device ! 3) Again that Webroot on your device might be is doing some shenanigans. Don't forget to run handle.exe or handle64.exe with Administrator !
  14. Kas Ob.

    GetIt alternatives

    Can't agree more on these, yet ... GetIt could simply be pulling a well structured and well thought JSON file from specific GitHub, this is Embarcadero managed GitHub repository, it will hold a list of sources from GitHub or any where else, with a mark "Verified or Emb.Ready" or "Not Verified ! use on your own" So in GetIt you will have the Official sources and non-official ones, also it could list stuff like development or beta or debug.... or many many things, simplifying the whole process, anyone can upload or pull a request to a repository and GitIt Maintainer will list them under categories ... many things can be suggested here, the point is user of GitIt will have way more richer experience, resources, EULA ..., with minimal interaction from Emabrcadero staff or timing, also such GitIt can have its own or user supplied repository like the official one, again, here one can put his own code. Is that much or impossible to implement ?, i guess current GetIt took way more time to evolve to be stable (i never used it), yet to fail like that today, after all why it is not opensource itself ? any particular reason ?!
  15. Kas Ob.

    Delphi 12: Invalid class typecast

    I am sorry ! I thought putting such interfaces resolver in the exception handler for failed "as" casting could show log better information about the missed interface implementation hence the failed casting.
  16. Kas Ob.

    Delphi 12: Invalid class typecast

    May i suggest this alternated code from Remy (i hope with his permission) https://stackoverflow.com/questions/39584234/how-to-obtain-rtti-from-an-interface-reference-in-delphi type ITest1 = interface ['{5AB029F5-31B0-4054-A70D-75BF8278716E}'] procedure Test1; end; ITest2 = interface ['{AAC18D39-465B-4706-9DC8-7B1FBCC05B2B}'] procedure Test1; end; TTest = class(TInterfacedObject, ITest1, ITest2) public procedure Test1; procedure Test2; end; procedure TTest.Test1; begin //... end; procedure TTest.Test2; begin //... end; function GetInterfacesFromItsObj(AIntf: IInterface): string; var obj: TObject; IntfType: TRttiInterfaceType; ctx: TRttiContext; tmpIntf: IInterface; begin obj := AIntf as TObject; Result := 'Object: (' + obj.ClassName + ')_ -> : '; for IntfType in (ctx.GetType(obj.ClassType) as TRttiInstanceType).GetImplementedInterfaces do begin if obj.GetInterface(IntfType.GUID, tmpIntf) then begin Result := Result {+ 'Intf: '} + IntfType.Name + ', '; tmpIntf := nil; end; end; end; procedure TForm10.FormCreate(Sender: TObject); var Intf1: ITest1; Intf2: ITest2; begin Intf1 := TTest.Create as ITest1; Intf2 := TTest.Create as ITest2; ShowMessage(GetInterfacesFromItsObj(Intf1)); end; The result
  17. Kas Ob.

    Delphi 12: Invalid class typecast

    If i to read this right, then the exception was not here at all, and this one is a nested one, in other words this one is raised while handing a previous (and original) exception. Also the stack is cut !, where is the rest of it ? does this dialog have more text without scroll bars ? or this is it ? Also would you please try to track the actual disk operations with Process Monitor ? in other words, were there a successful/failure File Write operations right before this dialog ?
  18. Hi, Yes, it is half of the problem in your case, here you didn't mention who is the owner of the EXE and the owner of the parent folder, both these values plays role, The other half is either 1) System Protection has kicked in and sees that file (folder) as valuable and important, in this case there is copies and copies in the hidden/strict restore folder (System Volume Information) on the drive, you need to disable the protection and clear that folder then enable if you want it. 2) Windows Defender has kicked in and most likely sent the exe sample to Microsoft labs, i never ran this cloud protection (my main developing machine is still Windows 10), so don't know exactly what it does or how it behave, https://learn.microsoft.com/en-us/microsoft-365/security/defender-endpoint/cloud-protection-microsoft-antivirus-sample-submission?view=o365-worldwide Also you can run Process Monitor https://learn.microsoft.com/en-us/sysinternals/downloads/procmon remove/exclude all other processes and leave only BDS.exe in this case (to catch dcc32 operation), from there you should have the real and internal failure on API level this example of that same compiler error when the target exe is running and when was not
  19. Kas Ob.

    Delphi 12: Invalid class typecast

    Internet ?! Don't be scared - I always try to put some humor into my writing.
  20. Kas Ob.

    New and easy Format Command (OpenSource)

    Thank you! Just one think to explain and make it clear This is not exactly about laziness, but also about how smooth it goes in slow brain like mine: TNetFormat instantly invokes Network, Internet, protocol standard... FStr instantly invokes a local field in Self or even local variable... Anyway, thank you again and it is of course up to you to name it, for me i would not use it like that with these names, i will rename a type from it, something with clear path/history in my brain then use it, something shiny and unique 🤓
  21. Kas Ob.

    New and easy Format Command (OpenSource)

    Why not VoStr or VoFmt ? Short and easy to remember.
  22. Kas Ob.

    SSL connection

    https://www.yunqa.de/delphi/products/openssl/index remove the need to OpenSSL altogether if the need is only for secure connection https://www.devart.com/sbridge/ great price, full source, decent performance and extensive documentation with DevArt support engine, from https://www.devart.com/sbridge/editions.html also with full SSH support ! https://www.streamsec.com/index.php?id=orderstrsecii v2.3 is old but still working last time i used it https://www.streamsec.com/index.php?id=orderstrseciv v4 is more expensive, never used it
  23. Kas Ob.

    Delphi 12: Invalid class typecast

    The line number is there, in the stack call. What needed is try.except to minimize the overhead in such places where errors/exceptions reported, while in the according exception handler a small RTTI piece of code to extract and report the offending class, the one that most likely shouldn't be there or simply lost one Interface from its definition because it is so rare to that had being missing such declaration, getting its type info should be trivial, (i think)
  24. Kas Ob.

    Delphi 12: Invalid class typecast

    My thoughts here : 1) Evidently from the stack, the exception raised by using the "as" operator. 2) This could be captured or even prevented but in all cases it can be logged and reported in better detailed report (or error message) than leaving it to the IDE to handle the exception.
×