Any ideas how I can send a file and make sure the server identifies all the chunks as one file?So why not parse the result from aSocket.GetMessage(s) correctly and split the received chunks back to individual packets?
IF it's send in irregular chunks, the server recognizes only the first one, next chunks are sent without the code and hash.So yeah. Try to find out why this goes wrong at the server end.
but it's send in chunks of 1408 bytes, some chunks differ. The problem is that the message consists of a code (for the server to know what type of message it is), hash and a JPG file. IF it's send in irregular chunks, the server recognizes only the first one, next chunks are sent without the code and hash.
Then I got an idea to chop the message into 1024-byte chunks and send each piece with the code and hash so the server knows what file it belongs to but even though I send it in 1024 bytes, the server still receives random pieces.
Any reason you are using yet another internet library? My advice is to look at the ssockets unit (fcl-net package) which comes with FreePascal/Lazarus.
There is an example of client/server programming in:
isockcli.pp and isocksvr.pp
Whenever I need to transfer data, I use fphttpserver & fphttpclient.
I prefer Indy, but I also like to keep project dependencies to libraries which come with FreePascal/Lazarus. It makes porting a whole lot easier.
My advice is to look at the ssockets unit (fcl-net package) which comes with FreePascal/Lazarus.I didn't even know it existed :o, 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 (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.