Recent

Author Topic: Synapse TTCPBlockSocket Send and Receive issue  (Read 3483 times)

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Synapse TTCPBlockSocket Send and Receive issue
« on: October 17, 2014, 08:08:17 pm »
Hi,

I need to use TTCPBlockSocket on client side. I need to listen for server messages so I moved TTCPBlockSocket.RecvString(100) to another thread loop. The problem is that I also need same socket to send messages from main thread. I suppose that I need to use critical sections to avoid deadlocks. I'm worrying about efficient because TTCPBlockSocket.RecvString(100) routine need to be also between critical section access (100 milliseconds sleep). Is exists any other way to do this? Maybe better use TApplication.OnIdle event and call RecvString there? I know that LNet are non-blocking but I must use Synapse.

Regards

jarto

  • Full Member
  • ***
  • Posts: 106
Re: Synapse TTCPBlockSocket Send and Receive issue
« Reply #1 on: October 17, 2014, 08:24:29 pm »
You can basically read from a socket and write to it in another thread simultaneously without critical sections. However, with Synapse, there is one problem: Both the reading and writing changes the FLastError and FLastErrorDesc properties.

I've worked around the problem by overriding RecvPacket and SendBuffer.

 

TinyPortal © 2005-2018