pls advise why this happens.
on a simple sample server app i have the following code:
procedure TForm13.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var str : string;
begin
str := socket.ReceiveText;
showmessage(str);
end;
and on the client side i have
clientsocket1.Open;
clientsocket1.Socket.SendText(txtMSG.Text);
nothing fancy.
the strange thing is that when i send a message to the server for 1st time it gets ignored. every time after that it works great. the ClientRead event doesn’t fire off at all on the 1st message
what can i change on the server to make it accept the 1st message.
I have no control over the client side as a 3rd party sends me messages, ut i am always missing the 1st message.
thanks!
If you are using the
TClientSocketin non-blocking mode (which is the default), you can’t send data immediately afterOpen()returns, as the connection is not ready yet. You have to wait for theOnConnectevent to be triggered first, eg: