A
anzhiping
Unregistered / Unconfirmed
GUEST, unregistred user!
var
x:Tsocket;
selfaddr,theiraddr:Tsockaddr;
tos:char;
buf:array [1..100] of byte;
i:integer;
p:integer;
begin
for i:=1 to 100 do
buf:=i;
x:=socket(AF_INET,SOCK_DGRAM,0);
selfaddr.sin_family :=AF_INET;
selfaddr.sin_port:=htons(6000);
selfaddr.sin_addr.S_addr:=htonl(INADDR_ANY);
bind(x,selfaddr,sizeof(Tsockaddr));
theiraddr.sin_family:= AF_INET;
theiraddr.sin_port :=htons(6000);
theiraddr.sin_addr.S_addr:=htonl(inet_addr('202.117.15.170'));
tos:=chr(30);
setsockopt(x,SOL_SOCKET,IP_TOS,@tos,sizeof(byte));
p:=sendto (x,buf,100,0,theiraddr,sizeof(theiraddr));
// if p>0 then
showmessage(inttostr(p));
closesocket(x);
end;
在发送分组后,返回结果为-1,没有发送成功,为什么。
x:Tsocket;
selfaddr,theiraddr:Tsockaddr;
tos:char;
buf:array [1..100] of byte;
i:integer;
p:integer;
begin
for i:=1 to 100 do
buf:=i;
x:=socket(AF_INET,SOCK_DGRAM,0);
selfaddr.sin_family :=AF_INET;
selfaddr.sin_port:=htons(6000);
selfaddr.sin_addr.S_addr:=htonl(INADDR_ANY);
bind(x,selfaddr,sizeof(Tsockaddr));
theiraddr.sin_family:= AF_INET;
theiraddr.sin_port :=htons(6000);
theiraddr.sin_addr.S_addr:=htonl(inet_addr('202.117.15.170'));
tos:=chr(30);
setsockopt(x,SOL_SOCKET,IP_TOS,@tos,sizeof(byte));
p:=sendto (x,buf,100,0,theiraddr,sizeof(theiraddr));
// if p>0 then
showmessage(inttostr(p));
closesocket(x);
end;
在发送分组后,返回结果为-1,没有发送成功,为什么。