Y
younghat
Unregistered / Unconfirmed
GUEST, unregistred user!
使用TWinSocketStream进行同步数据交换,代码如下:
var
SocketStream:TWinSocketStream;
buf:array[0..10000] of char;
timeout,i:integer;
begin
timeout:=5000;
StrPCopy(buf,Memo1.Text);
SocketStream:=TWinSocketStream.Create(self.ClientSocket1.Socket,timeout);
SocketStream.Write(buf,timeout);
SocketStream.WaitForData(timeout);
……
end;
问题是,实际传送的内容长度不能确定,即使我用buf:array[0..1000000] of char;也无法保证长度不会超过。
我该怎么办,各位大侠救我。
var
SocketStream:TWinSocketStream;
buf:array[0..10000] of char;
timeout,i:integer;
begin
timeout:=5000;
StrPCopy(buf,Memo1.Text);
SocketStream:=TWinSocketStream.Create(self.ClientSocket1.Socket,timeout);
SocketStream.Write(buf,timeout);
SocketStream.WaitForData(timeout);
……
end;
问题是,实际传送的内容长度不能确定,即使我用buf:array[0..1000000] of char;也无法保证长度不会超过。
我该怎么办,各位大侠救我。