Thank you guys for your quick replies. I reply here to your different messages.
Kirk Dunlap wrote: > Geppy, > It would be helpful to see how you are receiving it. Show us some code on > the receive side of this. as server I used the one contained in Wilfried's example server1.zip at http://tinyurl.com/cqkmh The ClientDataAvailable event is the following one: procedure TForm1.ClientDataAvailable(Sender: TObject; Error: Word); var Count: integer; begin if Error <> 0 then begin Log(ltError, 'ClientDataAvailable', Error); Exit; end; with Sender as TClient do try //ResetTimer; Count := Receive(Rcvd + WritePtr, RcvdSize - WritePtr); if Count <= 0 then // check if we received something Exit; if IsRcvBin then begin inc(WritePtr, Count); // calculate pointers if RcvdSize - WritePtr < 1024 then // are we running out of buffer space begin //inc(RcvdSize, 8192); RcvdSize := RcvdSize * 2; ReAllocMem(Rcvd, RcvdSize); end; if WritePtr = RcvdCount then // have we received all we need ReceiveBinComplete; Exit; end; if Count <= 2 then Exit; Rcvd[Count - 2] := #0; // we have to make it null terminated for the interpreter CommandInterpreter; except on E: exception do Log(ltError, 'ClientDataAvailable', E.Message); end; end; This server implements a simple protocol: a text command 5 characters long followed by some data. ------------------ Arno Garrels wrote: > Is LineMode enabled on the server-side? No, LineMode is False. > What does your DataAvailable handler on the server? Please see above. ------------------ Wilfried [TeamICS] wrote: > Not needed to switch LineMode at the sender. TWSocket will only use > lineMode whilst receivin. > Also better to work event driven between the 2 applications: > - send data whitch tell receiver you want to send a certain binary > - receiver set linemode to false and answer 'ok i'm ready' > - sender send the binary when he received the 'ok ready' Maybe the problem is here. I send the command and the record without waiting any reply from server. > - receiver say 'ok received' and switch lineMode back on > - sender can go on now with next command if any > on sender lineMode may be switched on all the time as he does only > receive line based commands. I'll try this way. ------------------ Angus Robertson wrote: > The simplest improvement in your example would be work out the total > length of string and record, send that length first, followed by a short > string with length byte, then the binary record. Or just move the > string into the record (as ShortString). You then know exactly how much > data is being received, and can wait for as many packets as it takes. > It will not necessarily arrive in a single packet. In the real application, the records to be sent will be 3 or 4 different ones, so the server cannot knows in advance how much data it will receive. For this reason I'd like to implement a simple protocol like Wilfried did in his example, where the text command tells which record the client is going to send. Thank you for all your replies. Ciao. -- Geppy Piloni -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be