T
tianhf
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
var
wsd:TWSAData;
s:TSocket;
bOpt:ByteBool;
remote:SockAddr_in;
iphdr:IP_HDR;
udpHdr:UDP_HDR;
i,ret:integer;
iTotalSize,iUdpSize,iudpCheckSumSize,iIpVersion,iIpSize,ckSum:longWord;
ptrChar;
begin
if WSAStartup($202,wsd)<>0 then
begin
edit1.Text:='WSAStartup failed!';
exit;
end;
s:=WSASocket(AF_INET,SOCK_RAW,IPPROTO_UDP,0,0,0);
if s=INVALID_SOCKET then
begin
edit1.Text:='WSASocket failed!';
exit;
end;
bOpt:=true;
ret:=setsockopt(s,IPPROTO_IP,IP_HDRINCL,PChar(@bOpt),1);
^^^^^
if ret=Socket_Error then
begin
edit1.Text:='IP_HDRINCL failed! '+intToStr(WSAGetLastError());
exit;
end;
.........
上行返回的错误码 10022!!!!!!!!!!!!!!!
var
wsd:TWSAData;
s:TSocket;
bOpt:ByteBool;
remote:SockAddr_in;
iphdr:IP_HDR;
udpHdr:UDP_HDR;
i,ret:integer;
iTotalSize,iUdpSize,iudpCheckSumSize,iIpVersion,iIpSize,ckSum:longWord;
ptrChar;
begin
if WSAStartup($202,wsd)<>0 then
begin
edit1.Text:='WSAStartup failed!';
exit;
end;
s:=WSASocket(AF_INET,SOCK_RAW,IPPROTO_UDP,0,0,0);
if s=INVALID_SOCKET then
begin
edit1.Text:='WSASocket failed!';
exit;
end;
bOpt:=true;
ret:=setsockopt(s,IPPROTO_IP,IP_HDRINCL,PChar(@bOpt),1);
^^^^^
if ret=Socket_Error then
begin
edit1.Text:='IP_HDRINCL failed! '+intToStr(WSAGetLastError());
exit;
end;
.........
上行返回的错误码 10022!!!!!!!!!!!!!!!