Hola,
Llevo varios dias atascado con un problema, he dado bastantes vueltas por internet sin encontrar solucion a lo que quiero realmente hacer.
Estoy trabajando en un Proxy Redirector, basicamente todo el trafico que le llega por un puerto de escucha, lo redireccione a otra IP & Port.
Funciona perfectamente para conexiones de 1 - Proxy - Servidor.
Pero cuando hay varias conexiones se hace un lio y sé perfectamente porque ocurre, pero no encuentro el parametro que me diga cual es la conexion realmente activa en ese momento para responderle por ese thread.
Código Delphi
[-]procedure TForm1.OnClientRead1(Sender: TObject; Socket: TCustomWinSocket);
var pakete:string;
Athread:integer;
begin
try
contador:=contador+1;
pakete:=Socket.ReceiveText;
ClientSocket1.Socket.SendText(pakete);
form2.richedit1.text:=form2.richedit1.text+#13+DateToStr(Date) +' ' +FormatDateTime('hh:nn:ss:zzz', Time)+' From Client: '+(Socket.RemoteHost)+#13+pakete+#13;
except
on E : Exception do
begin
ShowMessage('Exception class name = '+E.ClassName);
ShowMessage('Exception message = '+E.Message);
end;
end;
end;
procedure TForm1.OnRead1(Sender: TObject; Socket: TCustomWinSocket);
var
l:string;
begin
l:=Socket.ReceiveText;
Asocket1.SendText(l);
form2.richedit1.text:=form2.richedit1.text+#13+DateToStr(Date) +' ' +FormatDateTime('hh:nn:ss:zzz', Time)+' From Server: '+(Socket.RemoteHost)+#13+l+#13;
end;
ServerSocket1.Socket.Connections[AThread].SendText(pakete); <---- ahora mismo estaria respondiendo a todas las conexiones activas por el bucle, pero mi pregunta es como deberia realizarlo para responder al que me ha escrito? Socket.Connections[PARAMETRO QUE NECESIO CONOCER].SendText
Muchas gracias!