我有一个连接到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;我不知道我做错了什么,我和代理一起工作的不多,而且在工作中它不起作用,这不是一个工作项目,所以我不能在那里调试它。
提前谢谢。
发布于 2009-10-10 23:44:06
您知道TransparentProxy必须是SOCKS5代理吗?你用什么样的代理进行测试?
https://stackoverflow.com/questions/1549323
复制相似问题