请教各位大虾,问个Delphi中recvfrom的用法:(10分)

  • 主题发起人 主题发起人 netbug
  • 开始时间 开始时间
N

netbug

Unregistered / Unconfirmed
GUEST, unregistred user!
请看:<br>uses winsock;<br>procedure TForm1.Button1Click(Sender: TObject);<br>var err,j,k:integer;<br>wd:wsadata;<br>sk:tsocket;<br>ar,ar1:sockaddr_in;<br>buf:array [0..1000] of char;<br>begin<br>&nbsp; err:=wsastartup(2,wd);<br>&nbsp; sk:=socket(PF_INET,SOCK_RAW,IPPROTO_ICMP);<br>&nbsp; if sk&lt;&gt;INVALID_SOCKET then begin<br>&nbsp; ar.sin_family:=AF_INET;<br>&nbsp; ar.sin_addr.S_un_b.s_b1:=chr(192);<br>&nbsp; ar.sin_addr.S_un_b.s_b2:=chr(1);<br>&nbsp; ar.sin_addr.S_un_b.s_b3:=chr(1);<br>&nbsp; ar.sin_addr.S_un_b.s_b4:=chr(5);<br>&nbsp; ar.sin_port:=6123; end;<br>&nbsp; j:=bind(sk,ar,sizeof(ar));<br>&nbsp; k:=recvfrom(sk,buf,1000,0,ar1,sizeof(ar1));<br>end;<br>其中192.1.1.5是本地机子的IP,我在编译时,系统老是在<br>k:=recvfrom(sk,buf,1000,0,ar1,sizeof(ar1))提示:<br>[Error]:Types of actual and formal var parameters must be identical<br>我不知我的实参与形参在哪不一致,请各位大虾赐教,谢谢。
 
最后一个参数不对。<br><br>len:integer<br><br>len:=sizeof(ar1)<br><br>recvfrom(......,len)
 
接受答案了.
 
后退
顶部