2009-10-10 5 views
0

J'ai une application qui se connecte à un serveur udp, et je n'arrive pas à démarrer quand je suis derrière un proxy.UDP Connexion par proxy dans Delphi

Voici le code que j'ai, qui fonctionne bien lorsque Pas derrière un proxy.

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; 

Je ne sais pas ce que je fais mal, je n'ai pas travaillé avec des mandataires beaucoup, et il est au travail que cela ne fonctionne pas, et ce n'est pas un projet de travail, donc je peux Ne déboguez pas là.

Merci d'avance.

Répondre

Questions connexes