我用下面的一段代码捕捉不到错误~大侠们 help me ~~      try
 
           //发送返回基本状态请求
           IdUDPServer1.SendBuffer(ip,port, S[1],25);       except
           on exception do
           MessageDlg('发送信息失败!', mtWarning, [mbOK], 0);
       end;

解决方案 »

  1.   

    什么错误?是不是:
    Windows XP:  Controls whether UDP PORT_UNREACHABLE messages are reported. Set to TRUE to enable reporting. Set to FALSE to disable reportingfunction AllowUdpConnReset(Sd:TSocket;bNewBehavior:BOOL):BOOL;
    var
      dwBytesReturned:DWORD ;
      status:Integer;
      dwErr:DWORD ;
    begin
      Result := False;
      dwBytesReturned := 0;
      // disable  new behavior using
      // IOCTL: SIO_UDP_CONNRESET
      status := WSAIoctl( sd, SIO_UDP_CONNRESET,
      @bNewBehavior, sizeof(bNewBehavior),
                       Nil, 0, @dwBytesReturned,
                       Nil, Nil);  if (SOCKET_ERROR = status) then
        begin
          dwErr := WSAGetLastError();
          if (WSAEWOULDBLOCK = dwErr) then
            begin
              // nothing to do
              Exit;
            end
          else
            begin
              Exit;
            end;
        end;
      Result := True;end;AllowUdpConnReset(FSocket,False);
      

  2.   

    这个错误Socket Error:#10054 
    用你的方法能解决吧?
    我现在不能立刻测试,所以不确定你的方法行不行。
      

  3.   

    WSAECONNRESET(#10054)
     For a UDP datagram socket, this error would indicate that a previous send operation resulted in an ICMP "Port Unreachable" message.你只要用上面的方法就可以解决相应的问题。
      

  4.   

    AllowUdpConnReset(FSocket,False);
    不好意思啊,我是菜鸟再问你一个问题怎么取得哪个错误的 FSocket  ???