LocalIP为本地IP
广播IP地址为:
procedure SetBroadCastIp;
var
i,j,iHead:Integer;
sHead,s:String;
ai:array [1..3] of integer;
begin
j:=1;
for i:=0 to Length(LocalIP) do
begin
if LocalIP='.' then
begin
ai[j]:=i;
Inc(j);
end;
if j>3 then break;
end;
sHead:=Copy(LocalIp,1,ai[1]-1);
iHead:=StrToInt(sHead);
if iHead<128 then //A类网
begin
BroadCastIP:=sHead+'.255.255.255';
end
else
begin
if iHead<192 then //B类网
begin
s:=Copy(LocalIP,1,ai[2]-1);
BroadCastIP:=s+'.255.255';
end
else //C类网
begin
s:=Copy(LocalIP,1,ai[3]-1);
BroadCastIP:=s+'.255';
end;
end;
end;