Recent

Author Topic: How to keep client connection open after handling TSocketServer OnConnect event  (Read 1486 times)

zamronypj

  • Full Member
  • ***
  • Posts: 133
    • Fano Framework, Free Pascal web application framework
[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

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
« Last Edit: July 13, 2019, 12:12:36 pm by zamronypj »
Fano Framework, Free Pascal web application framework https://fanoframework.github.io
Apache module executes Pascal program like scripting language https://zamronypj.github.io/mod_pascal/
Github https://github.com/zamronypj

 

TinyPortal © 2005-2018