Hello,
I have an application that connects to a udp server, and I can't seem to get it going when I am behind a proxy.
Here is the code I have, which is working fine when Not behind a 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;
I don't know what I'm doing wrong, I haven't worked with proxies much, and it is at work that it doesn't work, and it's not a work project, so I can't debug it there.
Thanks in advance.