I have several clients, who writes to one socket (not port), when they write together, I receive the garbage, all data from all clients are merged.
all clients are in the same program in Threads.
I need to lock write()
ASocket.Connection.Socket.LOCK; // need to be thread safe
ASocket.Connection.Socket.Write(buf);
ASocket.Connection.Socket.UNLOCK; // need to be thread safe
How can I do it ?
Thanks.
Delphi 2010, Indy 10, Win7
You can use
TCriticalSection(SyncObjsunit): put theWritebetweenEnterandLeave:The methods
AcquireandReleasedo the same (doc). Important: if you write to the socket at multiple points of your code, you must use the same object (the one I calledCriticalSectionin the above example).