Leaderboard
Popular Content
Showing content with the highest reputation on 08/28/23 in all areas
-
Class function vs constructor for object creation
Attila Kovacs replied to Michael Taylor's topic in Algorithms, Data Structures and Class Design
It's the Dopplebeau effect. Normal. Don't even bother with it. -
GDI+ DrawImage output differs by used printer on HighDPI system
ULIK replied to ULIK's topic in Windows API
I finally found a solution for this problem: the PNG images I printed had no pHYs chunks set (as they were initially created during runtime). As soon as the missing chucks were added, printing from high DPI systems works fine. The point is: it doesn't matter what exact values you are using, it's just that those chunks had to be set to a somewhat reasonable value. function TPaImageStrokeHelper.FixPNGPixelInformation(APNGImage: TPngImage): Boolean; begin Result := False; if not Assigned(APNGImage) then exit; if not APNGImage.HasPixelInformation then begin APNGImage.PixelInformation.PPUnitX := 3780; // relates to 96 DPI: 3780 Points / Meter APNGImage.PixelInformation.PPUnitY := 3780; APNGImage.PixelInformation.UnitType := utMeter; Result := True; end; end; -
IdTCPServer IdTCPClient knowledge.
Remy Lebeau replied to limelect's topic in Network, Cloud and Web
It is not impossible. You simply send the desired data using the IOHandler of the TIdContext object that represents the client on the server. But, you do have to be VERY careful when sending unsolicited (ie, non-requested) data from the server to a client. If you are not careful and send the unsolicited data incorrectly, you can easily corrupt your TCP communication. You need to make sure the client is not trying to request data at the same time that you are sending unsolicited data, or the client might misinterpret the data. Most protocols tat support unsolicited data design their messages in such a way that clients can identify what messages are unsolicited and what messages are responses to requests. Is this particular client EVER requesting data from the server? Or does the server ALWAYS initiate the sending? It makes a BIG difference in how you design your protocol and manage it in your code. So it is kind of difficult to answer your question definitively without knowing more about your communication needs. TCP is a 1:1 connection between client and server. There is no broadcasting. The data will be sent only to the specific client that you send it to. Are there ANY requests being sent from this client to the server? If yes, then you need to synchronize your sends so that unsolicited data does not overlap response data. This is typically done by creating a per-client queue of outgoing data, and then having the server's OnExecute event send the calling client's queue when it is safe to do so, ie when it is not servicing any requests. If no, then you can simply send data directly to the client whenever you want. There is no "peer number" in TCP. But, the server does have a unique socket handle (ie, TIdContext object) for each connected client. And you can always assign your own ID to each client, as well. You would simply send to whichever socket/context that you are interested in. This is typically handled inside the server's OnExecute event, using the TIdContext that is passed in as a parameter. But, depending on your needs, you can also search the server's Contexts list for the desired client and then send to it (if/when safe to do so). The PeerPort by itself is not adequate enough to uniquely identify clients. If clients connects to the server from different networks, they could use the same PeerPort. You would need the combination of PeerIP+PeerPort to uniquely identify each client. Better to just use the TIdContext objects instead, since they are already unique. Yes, it is. -
Can ICS thread cause memory violation? (EOutOfResources error)
Kas Ob. replied to PizzaProgram's topic in ICS - Internet Component Suite
@PizzaProgram Good luck ! Not only for that 😎, also for a slice of pizza 🍕- 76 replies
-
- thread
- eoutofresources
-
(and 2 more)
Tagged with:
-
Can ICS thread cause memory violation? (EOutOfResources error)
Kas Ob. replied to PizzaProgram's topic in ICS - Internet Component Suite
I think you are following the wrong thing here, even if this problem caused by loading and unloading OpenSSL which i doubt, but yet you can just log the loading and unloading operations with their result to a file and be sure. If my hunch is right and it is caused by the intense allocating and reallocating operation done by both AlphaSkin and ICS with OpenSSL, then minimizing these operation by caching objects and reusing will only minimize the effect and delay the inevitable, this bug is just like ticking bomb and you were unlucky enough that is not crashing sooner. I don't have My Delphi 7 at hand so checked an old projects and looked at the code without even running it, and here saw this gem In Utf8Encode there is this Length * 3, which assuming the size of UTF8 char would be 3 bytes at max, among this pasta with a call to WStrToPChar, which is mindboggling in the middle of converting a string to convert it first then convert it again, it seems Delphi 7 may be wrong in handling UTF8, it is +20 after all, and the fact UTF8String is used as RawByteString, raise even more questions. Now assuming ICS (with dropped Delphi 7 support) is right and not missing with such conversion, i suggest you try the following 1) Use UnicodeToUtf8 and Utf8ToUnicode directly instead of Utf8Encode and Utf8Decode. 2) Use more aggressive memory manager to detect corruption, really you should try EurekaLog, it is the best ability to all sort of memory malpractices along with leaks resources like GDI handles. 3) Log all the strings in raw format to a file, write them to a a memorysteam separated with some chars then flush that stream to the disk, se for yourself the result. Hope that help.- 76 replies
-
- thread
- eoutofresources
-
(and 2 more)
Tagged with:
-
What @mjustin meant is that normally a custom CONTEXT is used where for each connection received additional data can be inserted, such as an ID, a particular string of marking, or any other information we need for the activity. Example: TMyContext = class(TIdServerContext) // <-- must derive from TIdServerContext public /// <summary> This is a new RefID field </summary> RefID: UInt64; ChargeStr: string; end; //Somewhere, BEFORE activate the server assign MyContext to the component begin IdTCPServer1.ContextClass := TMyContext; IdTCPServer1.Activate := True; end; //In the Connect event you can initialize the Context procedure IdTCPServer1Connect(AContext: TIdContext); var Ctx: TMyContext; begin Ctx := TMyContext(AContext); Ctx.RefID := 0; Ctx.ChargeStr := ''; end; //Now you can use the new context whereever you want
-
Class function vs constructor for object creation
David Heffernan replied to Michael Taylor's topic in Algorithms, Data Structures and Class Design
This isn't true. Your class function calls the default constructor and that performs memory allocation. Free must be called. Instances of classes are heap allocated. -
There is no default 256 color palette. Old version of Windows "reserved" 16 fixed colors while new versions reserve 20 fixed colors. https://en.wikipedia.org/wiki/List_of_software_palettes#Microsoft_Windows_default_20-color_palette Changing the pixelformat to pf8bit forces the bitmap to use a color palette. I.e. instead of each pixel explicitly specifying the RGB color values, the pixels will contain an index into a palette of 256 colors. The colors in a palette generated by Windows will partially depend on the system palette which again depends on the Windows theme. https://learn.microsoft.com/en-us/windows/win32/gdi/system-palette-and-static-colors https://learn.microsoft.com/en-us/windows/win32/gdi/default-palette If you want a predictable result then you need to generate the palette using a predictable method: Either use a static palette or generate one using color quantization. There are methods in the GifImg unit for both solutions. https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.Imaging.GIFImg.ReduceColors
-
Actually, I think it's far better than most job reqs I've seen that all look like they were copy-pasted from a book of generic job descriptions. I think it would help if it mentioned the application domain(s) that they're hiring for, along with some typical tasks they expect to accompany some of the skill requirements. (Apache, Linux, Windows ... beyond writing code ... sounds like an IT role.)
-
We are pleased to announce the release of mORMot 2.1. The download link is available on https://github.com/synopse/mORMot2/releases/tag/2.1.stable The reference blog article was just published at https://blog.synopse.info/?post/2023/08/24/mORMot-2.1-Released Here is an extract of the release notes: Added (C)LDAP, DNS, (S)NTP clients Command Line Parser Native digest/basic HTTP servers authentication Angelize services/daemons manager TTunnelLocal TCP port forwarding SHA-1/SHA-256 HW opcodes asm 7Zip dll wrapper OpenSSL CSR support PostgreSQL async DB with HTTP async backend (for TFB) LUTI continous integration cross-platform farm Changed Upgraded SQLite3 to 3.42.0 Stabilized Mac x86_64/aarch64 platforms Lots of bug fixes and enhancements Any feedback is welcome! 🙂
-
Communication between Unicode and non-Unicode applications
Remy Lebeau replied to dummzeuch's topic in Indy
You don't need to use RawToBytes() in this case. The TIdIOHandler.Write(string) method has an optional ADestEncoding parameter to specify the byte encoding on the wire, such as UTF-8 (the default is ASCII). You can alternatively use the TIdIOHandler.DefStringEncoding property. And, in pre-Unicode versions, Write() also has an optional ASrcEncoding parameter to specify the byte encoding of the input AnsiString (the default is the user's OS default). Or, you can alternatively use the TIdIOHandler.DefAnsiEncoding property.