下面是一个编译过的程序
procedure TForm1.FormCreate(Sender: TObject);
begin
ClientSocket1.Close;
ServerSocket1.Close;
ServerSocket1.Open;
ClientSocket1.Open;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Buf : array [0..9] of real;
i : integer;
begin
for i:=0 to 9 do
begin
Buf := 0.05 + i;
Memo1.Lines.Add(FloatToStr(Buf));
end;
i := Length(Buf);
if ServerSocket1.Active then
ServerSocket1.Socket.Connections[0].SendBuf(Buf,i*SizeOf(real));
end;
procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
var
Buffer : array [0..19] of real;
i,m : integer;
begin
for i:=0 to 19 do
Buffer := 0;
m := Socket.ReceiveLength;
Socket.ReceiveBuf(Buffer,m);
m := m div SizeOf(real);
for i:=0 to m-1 do
Memo2.Lines.Add(FormatFloat('0.00',Buffer));
end;
end.