P
PROSE
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TMainForm.creatConnect();
Var
TmArracked array [1..81] of char;
_pos:word;
tmb:byte;
i,sPort :integer;
ServerBuff : Array[1..MAX_BUFF] of byte;
sVIP,err :string;
begin
_pos:=1;
tmb:=$01;
move(tmb,TmArr[_pos],SizeOf(Byte));
inc(_pos,SizeOf(Byte));
tmb:=$1F;
move(tmb,TmArr[_pos],SizeOf(Byte));
inc(_pos,SizeOf(Byte));
move(string('12345')[1],TmArr[_pos],5);
inc(_pos,2);
move(string('12345')[1],TmArr[_pos],5);
inc(_pos,5);
move(string('5')[1],TmArr[_pos],1);
inc(_pos,1);
move(string('12345')[1],TmArr[_pos],5);
inc(_pos,5);
tmb:=$02;
move(tmb,TmArr[_pos],SizeOf(Byte));
inc(_pos,SizeOf(Byte));
AddParityChar(TmArr);
IdUDPClient1.sendbuffer(TmArr,_pos-1);
memo1.Lines.Add('udp has send');
sPort:=2000;
sVIP:='211.93.128.192';
IdUDPClient1.ReceiveBuffer(serverbuff,i,sVIP,sPort,-1);
if ServerBuff[2]=$03 then
begin
memo1.Lines.Add('connect succeed!');
end;
if ServerBuff[2]=$04 then
begin
case ServerBuff[3] of
01 : err := '校验出错。';
02 : err := '号码越界' ;
04 : err := '包结构错误';
09 : err := '系统忙';
13 : err := '登录密码错误';
14 : err := '操作超时';
end;
memo1.Lines.Add(err);
end;
// timer.Interval := TIMEINTERVAL;
// timer.Enabled := True;
// memo1.Lines.Add(inttostr(i));
end;
procedure TMainForm.AddParityChar(var buffer: array of Char);
var
i, Len, Count: Integer;
begin
Len := StrLen(buffer);
Count := 0;
for i := 0 to Len - 1 do
begin
Inc(Count, Ord(buffer));
end;
buffer[Len] := Chr((Count mod 16) + Ord('0'));
end;
IdUDPClient1.ReceiveBuffer(serverbuff,i,sVIP,sPort,-1);
是不是可以收到服务器发送回来的包???
我的程序包一发送出去程序就死了,是不是该用个多线程处理一下??如何写,第一个是连接,第二个是校验方法
Var
TmArracked array [1..81] of char;
_pos:word;
tmb:byte;
i,sPort :integer;
ServerBuff : Array[1..MAX_BUFF] of byte;
sVIP,err :string;
begin
_pos:=1;
tmb:=$01;
move(tmb,TmArr[_pos],SizeOf(Byte));
inc(_pos,SizeOf(Byte));
tmb:=$1F;
move(tmb,TmArr[_pos],SizeOf(Byte));
inc(_pos,SizeOf(Byte));
move(string('12345')[1],TmArr[_pos],5);
inc(_pos,2);
move(string('12345')[1],TmArr[_pos],5);
inc(_pos,5);
move(string('5')[1],TmArr[_pos],1);
inc(_pos,1);
move(string('12345')[1],TmArr[_pos],5);
inc(_pos,5);
tmb:=$02;
move(tmb,TmArr[_pos],SizeOf(Byte));
inc(_pos,SizeOf(Byte));
AddParityChar(TmArr);
IdUDPClient1.sendbuffer(TmArr,_pos-1);
memo1.Lines.Add('udp has send');
sPort:=2000;
sVIP:='211.93.128.192';
IdUDPClient1.ReceiveBuffer(serverbuff,i,sVIP,sPort,-1);
if ServerBuff[2]=$03 then
begin
memo1.Lines.Add('connect succeed!');
end;
if ServerBuff[2]=$04 then
begin
case ServerBuff[3] of
01 : err := '校验出错。';
02 : err := '号码越界' ;
04 : err := '包结构错误';
09 : err := '系统忙';
13 : err := '登录密码错误';
14 : err := '操作超时';
end;
memo1.Lines.Add(err);
end;
// timer.Interval := TIMEINTERVAL;
// timer.Enabled := True;
// memo1.Lines.Add(inttostr(i));
end;
procedure TMainForm.AddParityChar(var buffer: array of Char);
var
i, Len, Count: Integer;
begin
Len := StrLen(buffer);
Count := 0;
for i := 0 to Len - 1 do
begin
Inc(Count, Ord(buffer));
end;
buffer[Len] := Chr((Count mod 16) + Ord('0'));
end;
IdUDPClient1.ReceiveBuffer(serverbuff,i,sVIP,sPort,-1);
是不是可以收到服务器发送回来的包???
我的程序包一发送出去程序就死了,是不是该用个多线程处理一下??如何写,第一个是连接,第二个是校验方法