DeveloppeurPascal / Socket-Messaging-Library

A client / server messaging library to use with TCP sockets in Delphi or C++Builder (one day in the future)
https://socketmessaging.developpeur-pascal.fr
GNU Affero General Public License v3.0
18 stars 3 forks source link

How to 'Correctly' Close a Connection #109

Open Mr-KultiVator opened 9 months ago

Mr-KultiVator commented 9 months ago

Congratulations on a genuinely useful library for Delphi - and one with exciting cross-platform potential too!

I've been experimenting with the library and I'm enjoying using it.

One small issue I've had is that I've not discovered in the source code or the online demos the correct way to close/terminate a connection once it's established. (I have an application in mind where multiple connections/disconnections are often required through the course of a single execution of the application.

Many thanks for your work on this library and the video tutorials and Embarcadero event you presented at.

DeveloppeurPascal commented 9 months ago

Hi

Thanks for your comment. ;)

To disconnect just destroy (Free or FreeAndNil) your client instance. The socket should close locally and inform the server.

I have something to check/test and fix about disconnecting with TCP connections on the server side (for Mac, but will check the others). Current library should work as it for most little projects but if you have a lot of clients on the same server it could freeze it if you have network problems. I planned to work on this part in December or January.

For game usage or massive users I'll add an UDP version of the library and will try to make it as transparent as choosing UDP/TCP on the connexion.

We can talk about your project in private if you need something not implemented and don't want to share it publicly.

Did you used the generator to use the library or use it manually ?

DeveloppeurPascal commented 5 months ago

Hi. I've done some changes to fix anomalies on closing the server or a clients. Please check if it's ok for your use and tell me if anything need to be changed.

Mr-KultiVator commented 5 months ago

Thanks for sharing this update - I'll take a look when I'm next working in Delphi.

I hadn't spotted your previous question - I was initially just testing the basics of your library, as I've had some problems with Indy (on Android clients) and wanted to explore other options for a hobby project of mine.

If I can get the basics working reliably, I'd then be likely to progress to using your generator approach to build out the various kinds of messages & handlers, as that looks to eliminate writing lots of dull 'boiler-plate' code.