sockets - delphi tserversocket ignores 1st message -
pls advise why happens. on simple sample server app have following code:
procedure tform13.serversocket1clientread(sender: tobject; socket: tcustomwinsocket); var str : string; begin str := socket.receivetext; showmessage(str); end;
and on client side have
clientsocket1.open; clientsocket1.socket.sendtext(txtmsg.text);
nothing fancy. strange thing when send message server 1st time gets ignored. every time after works great. clientread event doesn't fire off @ on 1st message
what can change on server make accept 1st message. have no control on client side 3rd party sends me messages, ut missing 1st message.
thanks!
if using tclientsocket
in non-blocking mode (which default), can't send data after open()
returns, connection not ready yet. have wait onconnect
event triggered first, eg:
procedure tform1.startconnectingtoserver; begin clientsocket1.open; end; procedure tform1.clientsocket1connect(socket: tcustomwinsocket); begin socket.sendtext(txtmsg.text); end;
Comments
Post a Comment