Hello, Wilfried!
You have calmed me :)

Arno Garrels [TeamICS] wrote:
>As I understand the OP calls receive multiple times in OnDataAvailable
>which is not a good idea.

So, each Recv "launches" one more OnDataAvail in the future? If so, can I 
easily read from socket block-by-block? Here's what i do for now:

      // look for first byte of message start signature
      repeat res := Receive(@tmpC,SizeOf(tmpC)) until (res<=0) or 
      if res <= 0 then Exit;
      // check if the following bytes are really message start
      for tmpI := 2 to Length(MsgBeg) do
        if (Receive(@tmpC,SizeOf(tmpC))<=0) or (tmpC <> MsgBeg[tmpI]) then Exit;
      // get message type
      res := Receive(@tmpI,SizeOf(tmpI));
      // all OK, start receiving message
      FMsgType := TMsgType(tmpI);
      FInsideMsg := True;
      FBytesToRead := MsgLengths[FMsgType];

Should I create a state variable and do every receive in separate execution of 
OnDataAvail ?

Best regards, Anton
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to