0

udp サーバーに接続するアプリケーションがありますが、プロキシの背後にいると接続できないようです。

これが私が持っているコードです。プロキシの背後にない場合は正常に動作しています。

function TfrmMain.SendCommand(ServerName, IP: String; Port: Integer; Command: String): String;
var
  Udp : TIdUDPClient;
  Count : Integer;
  Response: String;
begin
  Result := '';
  Udp := TIdUDPClient.Create(nil);
  try
    try
      Udp.Host := IP;
      Udp.Port := Port;
      if UseProxy then begin
        Udp.TransparentProxy.Enabled := True;
        Udp.TransparentProxy.Host := ProxyServer;
        Udp.TransparentProxy.Port := ProxyPort;
        Udp.OpenProxy;
      end else begin
        Udp.TransparentProxy.Enabled := False;
      end;
      Udp.Connect;
      if Udp.Connected then begin
        //Send Command and receive data...
      end;
      if UseProxy then begin
        Udp.CloseProxy;
      end;
      Udp.Disconnect;
    except
      MessageBox(Handle, PChar('There was an error connecting to server ' + QuotedStr(ServerName) + '.  '), 'Error', MB_ICONERROR);
    end;
  finally
    Udp.Free;
  end;
end;

何が間違っているのかわかりません。プロキシをあまり使用したことがなく、動作しないのは仕事であり、作業プロジェクトではないため、そこでデバッグすることはできません。

前もって感謝します。

4

1 に答える 1

2

TransparentProxy がSOCKS5 プロキシでなければならないことを認識していますか? どの種類のプロキシでテストしていますか?

于 2009-10-10T23:44:06.070 に答える