W
wzca
Unregistered / Unconfirmed
GUEST, unregistred user!
我先定义了一个record 再用 SocketServer 和 SocketClient 传数据
传完一看,面目全非.
我只发送 Buff,也就是一个 Char 数组,好象就很正常。。。。
程序大约是这样的
-----------------------
const
BlockLen = 100;
type
PDataPackage = ^TDatapackage;
TDataPackage = record
ID: Shortint;
Max: Word;
CurrCount: Word;
Length: LongWord;
Buff: Array [0..BlockLen-1] of Char;
end;
----------发送------------------
var
MyData: PDataPackage;
begin
New(MyData);
MyData^.ID := 1;
MyData^.Max := 10;
MyData^.CurrCount := 1;
StrCopy(MyData^.Buff,'abcdefghijklmnopqrstuvwxyz1234567890');
MyData^.Length := SizeOf(MyData^.Buff);
Socket.SendBuf(MyData, SizeOf(MyData));
Dispose(MyData);
-----------接收----------------
var
MyData: TDataPackage;
begin
Socket.ReceiveBuf(MyData, SizeOf(MyData));
ss := 'New=>ID:' + IntToStr(MyData.ID);
ss := ss + ',Max:' + IntToStr(MyData.Max);
ss := ss + ',CurrCount:' + IntToStr(MyData.CurrCount);
ss := ss + ',Length:' + IntToStr(MyData.Length);
ss := ss + #13 + 'Buff:' + StrPas(MyData.Buff);
Memo1.Lines.Add(ss);
==============================
谁来给指导一下?
传完一看,面目全非.
我只发送 Buff,也就是一个 Char 数组,好象就很正常。。。。
程序大约是这样的
-----------------------
const
BlockLen = 100;
type
PDataPackage = ^TDatapackage;
TDataPackage = record
ID: Shortint;
Max: Word;
CurrCount: Word;
Length: LongWord;
Buff: Array [0..BlockLen-1] of Char;
end;
----------发送------------------
var
MyData: PDataPackage;
begin
New(MyData);
MyData^.ID := 1;
MyData^.Max := 10;
MyData^.CurrCount := 1;
StrCopy(MyData^.Buff,'abcdefghijklmnopqrstuvwxyz1234567890');
MyData^.Length := SizeOf(MyData^.Buff);
Socket.SendBuf(MyData, SizeOf(MyData));
Dispose(MyData);
-----------接收----------------
var
MyData: TDataPackage;
begin
Socket.ReceiveBuf(MyData, SizeOf(MyData));
ss := 'New=>ID:' + IntToStr(MyData.ID);
ss := ss + ',Max:' + IntToStr(MyData.Max);
ss := ss + ',CurrCount:' + IntToStr(MyData.CurrCount);
ss := ss + ',Length:' + IntToStr(MyData.Length);
ss := ss + #13 + 'Buff:' + StrPas(MyData.Buff);
Memo1.Lines.Add(ss);
==============================
谁来给指导一下?