TurboMagic
-
Content Count
235 -
Joined
-
Last visited
-
Days Won
9
Posts posted by TurboMagic
-
-
11 minutes ago, Fr0sT.Brutal said:Why do you need Socket.MessagePump at all?
I know that it would be better to not use it. It often works, but just not always.
In my case the routine running this shall already return the list of the search so after the code fragment shown in my post above,
which is in a loop going through all interfaces determined as plausible ones, I have a waiting loop so received answers which are
noted in some list have time to arrive. It's just to find out if a device answers to this request so it is present and to get it's IP. -
In order to obtain the list of interfaces I loop through I use IcsGetInterfaceList.
This returns 3 interfaces to me: 127.0.0.1 (loopback), which I skip, 10.149.x.y (x and y have valid numbers)
which is the IP of that VM I'm running in and the last one is 0.0.0.0.This is my code:
Socket := TWSocket.Create(nil); Socket.Proto := 'UDP'; Socket.Addr := '255.255.255.255'; Socket.Port := '1234'; Socket.LineMode := false; Socket.OnDataAvailable := OnUDPDataAvailable; Addr.S_addr := IfList[i]^.iiAddress.AddressIn.sin_addr.S_addr; Socket.LocalAddr := string(WSocket_inet_ntoa(Addr)); Socket.LocalPort := '0'; Socket.Connect; Socket.MessagePump; Socket.SendLine('Hallo?');
OnUDPDataAvailable is declared as method like this:
procedure TMyClass.OnUDPDataAvailable(Sender: TObject; ErrCode: Word);
-
I do set the interface because it is a broadcast to 255.255.255.255 and I want it to go out to all interfaces.
But: would that be really connected to the MessagePump crash in Application.ProcessMessages?
-
Hello,
in my project I ue ICS V8.62 in Delphi 10.3.3 to detect some devices on the network per UDP.
Sometimes my routine works as expected and sometimes it crashes.
When it crashes it happens on a call to Socket.MessagePump and inside that one
on the call to Application.ProcessMessages.My code is inside an Button click handler and it immediately crashes when pressing F7 in
the debugger on Application.ProcessMessages. Since it's a VCL app unit forms is used.Application is assigned.
My socket is a plain TWSocket, Proto is 'UDP' and local IP is set to one of the interfaces the computer
has to search on that one and LocalPort is 0.I call Socket.Connect and then immediately Socket.MessagePump where it crashes in.
Anybody any clue?
-
One issue with this is, that there didn't ask enough people about this yet. That's at least what SmartBear the company behind TestComplete told me.
Why don't all users liking to have such a thing ask all these vendors about it to show there's demand?
I'd start with TestComplete and with Ranorex, which even belongs to Idera but can only do VCL so far, as far as I know.
-
Oh and to help your decision what to do: participate in this nice project!
Look at missing algorithms and how to implement them so they fit to the architecture or create some more unit tests and turn them in...
There's a lot you can do to help! 😉
-
Confident now?
Remember: this is an open source project so could have implemented the proposed addition of readme.md yourself and
either turned it in as issue or created a pull request.Another possible answer would have been: look at the source Luke! 😉
-
Hello,
this is the notice that DEC (Delphi Encryption Compendium) has a new home.
The GitHub repository has been transferred to me by the previous maintainer as
he no longer found the time to work on it and I was the main developer since a
few years already anyway.The new URL is:
https://github.com/MHumm/DelphiEncryptionCompendium
This transfer also makes it a bit more likely that the V6.0 which is still in the works
will be released in the near future.Best regards
TurboMagic
- 2
- 3
-
On 10/2/2020 at 9:01 AM, Rollo62 said:Yes I have that, but the strings are so much more elegant.
I would whish to have better TBytes and dyn. array support like that in Delphi.You know that arrays can be concatenated with + since XE7? And delete etc. is available for them as well!
- 1
-
One thing which has helped at least some persons is to have a look at where units are put in uses. It often helped to put them into interface section rather than implementation section.
And somewhere else I read reports which compared 10.3.3 and 10.4.x both without fix pack and 10.4.x was measurably faster. It might not be as fast yet as everybody wishes, but at least noticeably faster.
Oh and somebody lately suspected it might have to do with unit scope like sometimes using SysUtils and sometimes System.SysUtils.
But that's a guess only.
-
Hello,
ICS is now moving to those SSL named classes, which is fine.
The question now is: in order to have a FTP client not using SSL is it enough to set the SSLType of the client component to "none"?
Best regards
TurboMagic
-
Small status update: it looks I have fixed all non object related issues. At least the unit tests for those do run and the same unit tests as implemented for unmanaged types have ben implemented for strings as well and they do run.
What's left now is the OwnsObjects semantics and tests for interfaces and regular classes. That's the state of the development branch.
-
I fixed the Add(Items:TRingbufferArray) now, it might need further test coverage for managed types, but that at least fixed some of the failed string test cases now.
Peek no longer crashes and while working on that I had see that Peek had already a value in Result at the beginning of the method. Trying to set that to Default(T)
there crashed immediately. So fixing add was the right thing.
One thing which still puzzles me and maybe is not even possible:
I can have such a generic ringbuffer class which works for non managed types and for reference counted types at the same time.
But I don't seem to be able to make it work with objects and OwnsObject semantics, as I cannot call free. I can only call free if I introduce a class constraint.
Is this assumption correct and my initial attempt with a class for objects inheriting from the first one is the right one?
I already tried to find out how TObjectList<T> from Generics.Collections does it, but I failed to find the free of the items in it...
-
Yes, I resolved it by upgrading the student to 10.3.3 and then using the permission request solution provided there.
It works now and if you check the github repo you'll see it's in there as well 😉
So if you need to create a video on Android you can use that solution right away 😉
The only thing missing there is an iOS implementation as I don't have any iPhone and Mac.
- 1
-
Access violation, but I don't know why.
Ok, I started to write some further unit tests now as a start to fix the issues this implementation has in order to learn some things.
I copied the integer unit tests which run fine and reworked those into string ones. so <T> is string now.
One of the tests calls this method:
function TRingbuffer<T>.Peek(Index: UInt32): T; var reminder : UInt32; begin if (Index < Count) then begin // Puffer läuft derzeit nicht über seine obere Grenze hinaus if ((FStart+Index) < Size) then result := FItems[FStart+Index] else begin // um wieviel geht es über die obere Grenze hinaus? reminder := (FStart+Index)-Size; result := FItems[reminder]; end; end else raise EArgumentOutOfRangeException.Create('Invalid Index: '+Index.ToString+ ' Max. Index: '+Count.ToString); end;
FItems at that point contains 5 items, FStart is 1 and Index is 1 as well.
It crashes with EInvalidPointer at this line:
result := FItems[FStart+Index]
When debugging the asm I see some call to freemem.
I would have expected that Peek would simply return a string with the contents of FItems[FStart+Index] and that it would increase the
reference counter of the string stored in FItems[FStart+Index].This Peek method is called in a loop over the complete ringbuffer to check if its contents is the expected one.
For Index = 0 it doesn't crash.
What is wrong on my assumption?
And the other question would be: should peek increase reference counter of reference counted types (string, interface...) or return
a copy which is not reference counted and thus completely detached from the buffer inside the ring buffer class?And if "detached" should be preferred, how to do the copying properly?
-
By the way: the whole thing is now available here:
https://github.com/rmesch/Bitmaps2Video
Android 64 bit support for the sample provided should be available soon, I need to commit it and create a pull request.
Which I'll do in a minute.- 1
-
On 6/8/2020 at 11:40 AM, David Heffernan said:Couldn't take the traffic of tens of devs trying to vote for range checking enabled by default
I guess it's rather a missing overflow check in the server software for the vote counter 😉
But I guess this Jira software is not written in Delphi (oh, if it were overflow checking would be available and this issue would have been caught during testing...)Of course I voted for this as well.
-
If your Delphi version is new enough to support generics:
Create a TDictionary where the key is the number (ID) of the question and the data is the number of points of the answer selected.
Store the ID of the question in the tag of the tab the question is on (assuming one tab holds one question, if not put each question
in some container which has a tag, it doesn't matter if that container is visible or not). Store the number of points associated with an
anwer to the question in the tag of the checkbox or radio button for the answer.If somebody selects an answer look in the list if there is already some entry with hat question ID. If yes, remove it and add it again with
the new data or overwrite the data.When the questionaire is finished iterate through the dictionary and count the points.
uses Generics.Collections; type // first one is the key = question ID, last one the data asociated with the key in your case the points. TAnswerDict = Dictionary<integer, integer>; var Answers:TAnswerDict; Pair: TPair; Points: Integer; begin Answers := TAnswerDict.Create; try Answers.Add(1,3); Answers.Add(2,1); Points := 0; for Pair in Answers do inc(Points, Pair.Value); finally Answers.Free; end; end.
The code has not been tested but it should be a starting point for you, if still relevant.
-
Ok, besides accepting Uwe's pull request I did some changes to the Peek method in order to make it more compatible with managed types. Feel free to look at it and critisise where necessary, I admit that I didn't test it yet (need to create unit tests) but it's getting late enough already. I can only learn from it.
And if somebody wants to contribute: feel free. As far as I understood Stefan, one could get rid of the 2nd class implemented for managed types altogether by using IsManaged and calling the appropriate code to release the items where necessary.
-
1 minute ago, Anders Melander said:Move isn't the problem in this particular case. The problem is that once you logically remove an entry from the array then you need to finalize that entry in the array to clear the reference. You can do that by assigning Default(T) to the entry.
Ok, thanks for this hint.
-
19 minutes ago, Anders Melander said:Because otherwise the buffer will still hold a reference to the T instance. For any managed type this will be a problem.
For example what happens if T is an interface?
Maybe some unit testing is in order...
Yes, unit tests for managed types would still have to be created. And yes one would have to do some for strings and interfaces as well as tey're of course managed as well.
I contributed this to the public because it will not help the community if one always consumes only without giving. That also means, if there's interest in this library others should contribute fixes etc. as well. My main open source commitment currently is DEC (Delphi Encryption Compendium) and that's enough work.
-
4 minutes ago, Anders Melander said:Because otherwise the buffer will still hold a reference to the T instance. For any managed type this will be a problem.
For example what happens if T is an interface?
Maybe some unit testing is in order...
Thanks! That could be fixed at the place where items get taken out of the list. I guess one would have to make a distinction of cases via
IsManagedType(T) so one can keep using Move for non manages types and assignment operator for managed ones. Would that be correct?
-
9 hours ago, Stefan Glienke said:No, yes
For managed types you can System.Move them in the internal array - however it also does it when peeking x items into the result array.
For types containing weak reference System.Move does not work even for the internal array.
Ok, I think I see what you're after. In case of the peek one would have to use the assignment operator then (if the type is a managed one) in order to increase the reference counter. Am I right? But how to find out whether the type is managed?
-
9 hours ago, Anders Melander said:I can't see why using Move would be a problem as long as it just moves entries within the buffer array (which it does as far as I can tell).
However there does seem to be a problem with not clearing empty slots in the array. E.g. by assigning Default(T) to them.
Why would those have to be cleared? One shoukdn't be able to read those out and I don't remember but if the buffer has to free any instances contained in it when the buffer is freed it will only free the instances still in the buffer.
ICS crash
in ICS - Internet Component Suite
Posted · Edited by TurboMagic
Is there really such an OnSessionConnected event on a connection less UDP socket?
Remember: I'm using UDP here.