@rvk, thank you very much for the answer. I could modify the server so as soon as it recognizes the type of message to be a file, it'd assume that everything that comes next is a part of the file instead of parsing each chunk. However, this solution may fail if something happens on the way, if one of chunks is lost, it'd be still stuck to the expected file size. For now this solution might work, I'll implement it, I'll add the file size to the header and see what other issues I may face :-)
@derek.john.evans and MarkMLl, no, there is no particular reason for using lNet, it's just that I'm new to Lazarus+Networking so I just googled "Lazarus WebSockets", first I found was LazWebSockets by @Warfley, it seems pretty cool, it's threaded etc (I'm learning threads and WebSockets, I need them both) but there is not much documentation and it was hard to find any help so I switched to the second solution google gave me - lNet, it seems pretty complete, so far it works as needed, however not exactly as expected (but I guess it's just due to lack of knowledge on WebSockets and networking in general).
My advice is to look at the ssockets unit (fcl-net package) which comes with FreePascal/Lazarus.
I didn't even know it existed
, I will take a look. I reviewed the demos you mentioned and I reviewed its source code. It seems to work a little bit different to lNet, I will give it a try. I found this
https://wiki.freepascal.org/Sockets but it's rather outdated, it mentions visual component, is it still the case? I can't find any and visual components might help me, especially for the client side.
but I also like to keep project dependencies to libraries which come with FreePascal/Lazarus. It makes porting a whole lot easier.
so do I, I used LazWebSockets and lNet only becasue I didn't know ssockets unit existed.