ENet - Reliable UDP networking library lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- BlackDoomer · 2015-03-26 10:26 ENet - Reliable UDP networking library Official website Shortcut of it's features list: Own socket system over UDP like Berkley sockets.Packets could be sent both in reliable and unreliable modes through the same socket.All packets are right-ordered, regardless of reliability, but an ability to send unsequenced packets like pure UDP is also here.Channels, the feature that is really awesome. Read this as "independently ordering sequences of packets".It provides REALLY FAST networking without any serious latencies on large pings, and at the same time it is very easy to use. In summary, ENet provides you to fast reliable protocol that is between UDP and TCP and have the best features from both of them. You can read more detailed information at ENet website, for example: features list or brief tutorial. Here you can download translated ENet headers to use it with FreePascal. At beginning, I translated ENet library headers for Delphi 7 to use it in Doom 2D: Forever (if you're interested, you can take them here at project GitHub). After that, I've decided to adapt them for FreePascal due to small amount of changes to perform that. So, here they comes. https://github.com/cher-nov/enet-fpc Hope that this will be useful for someone. Any feedback and criticism are also welcome. ---------------------------------------------------------------------- JZS · 2015-03-26 11:24 Good efforts. I will try it. Thanks for sharing it. ---------------------------------------------------------------------- rasberryrabbit · 2015-04-16 05:15 I converted old enet to pascal source.  https://github.com/rasberryrabbit/enet-freepascal ---------------------------------------------------------------------- MvC · 2015-04-18 11:14 I added the headers, but removed all _ from unit names, and changed the extension to .pp I also added a slightly adapted version of the class that can be found in https://github.com/rasberryrabbit/enet-freepascal I additionally created some example command-line client and server apps that demonstrate how to use this class. All was tested on linux and found to work correctly. ---------------------------------------------------------------------- hallenberger · 2015-04-18 12:19 Where is "INVALID_SOCKET" defined on linux/fpc? ---------------------------------------------------------------------- marcov · 2015-04-18 12:54 To my best knowledge that is a winsock specific identifier, so in Winsock or winsock2. Correction, it seems not defined on linux, but is seems to be in sockets for e.g. BSDs. ---------------------------------------------------------------------- BlackDoomer · 2016-08-02 16:50 I've recently revised the translated headers and, unfortunately, found some issues. First of all, C headers were translated directly into Pascal modules (units), but, as it's generally known, they're quite different things. This happened because Pascal was a fairly new language for me, so I misunderstood some of it basic principles. Because of this, I decided to merge all units into one module. Secondly, original ENet headers aren't separated into external (API) and internal parts, so I automatically translated some structure definitions that aren't needed for DLL usage. I've removed them from the revised version. And thirdly, when C enum is just a simple grouping type so you can use its constants as they were simply macro definitions, this doesn't apply to Free Pascal where enums are entirely separate types. So I redefined those enums which were defined only for grouping purposes, to the simple constants. So I've uploaded new version of the headers, and updated link in the first post. ---------------------------------------------------------------------- Thaddy · 2016-08-02 16:58 Quote from: Black Doomer on August 02, 2016, 06:50:45 pmAnd thirdly, when C enum is just a simple grouping type so you can use its constants as they were simply macro definitions, this doesn't apply to Free Pascal where enums are entirely separate types. So I redefined those enums which were defined only for grouping purposes, to the simple constants. Actually that is not the whole story. If you would have used h2pas to translate the headers - to some extend - you have the option in h2pas to translate C(++) enums into consts directly. There isn't much difference and they are casteble anyway. What you write is incorrect. An enum type in Pascal is also a simple grouping type, but a little more powerful. But translating C enums into pascal consts is also valid and won't hurt (much). See the h2pas documentation. .. And ahum, why wouldn't other UDP solutions in pure pascal NOT be reliable? I mean Synapse is just as reliable (and fast!). And there are many more. But I will run some speed and reliability tests anyway. ---------------------------------------------------------------------- BlackDoomer · 2016-08-02 17:17 Quote from: Thaddy on August 02, 2016, 06:58:36 pmIf you would have used h2pas to translate the headers - to some extend - you have the option in h2pas to translate C(++) enums into consts directly. There isn't much difference and they are casteble anyway. What you write is incorrect. It was just about C-style enum usage. Of course, I can cast, and know about it. Quote from: Thaddy on August 02, 2016, 06:58:36 pm.. And ahum, why wouldn't other UDP solutions in pure pascal NOT be reliable? I mean Synapse is just as reliable (and fast!). And there are many more.Because pure UDP doesn't provide you any guarantees about transmission order, data correctness and consistency and other. ENet implements TCP-like protocol over UDP, but much more lightweight and optimized for real-time applications (e.g. games).