Lazarus

Programming => Networking and Web Programming => Topic started by: zamronypj on June 23, 2019, 06:45:27 am

Title: How to keep client connection open after handling TSocketServer OnConnect event
Post by: zamronypj on June 23, 2019, 06:45:27 am
[SOLVED]

Please correct me if I am wrong.

Source code of TServerSocket class 

https://github.com/graemeg/freepascal/blob/master/packages/fcl-net/src/ssockets.pp (https://github.com/graemeg/freepascal/blob/master/packages/fcl-net/src/ssockets.pp)

tells me that when we handle its OnConnect event, it is developer's responsibility to free socket stream instance when they are done, otherwise we will leak memory.
Freeing socket stream will cause client socket connection to be closed.

Due to network protocol requirement, sometime my server application is required to leave client socket connection open after server application done sending data to client (the client will be responsible to close socket connection). In this condition, it becomes problematic, not freeing socket stream leading to memory leak, but freeing socket cause server application not conform network protocol.

How do I solve this without need to create new classes inherited from TInetServer/TUnixServer and also TInetSocket/TUnixSocket?

I solved it by implementing my own socket server. See my related post

https://forum.lazarus.freepascal.org/index.php/topic,45972.0.html