A라는 곳에서 NAK를 받으면 A로 재전송하는지 전혀 다른 B라는 곳으로 재 전송하는지 모르겠습니다.
A에서 받아서 A로 전송하면,
<!--CodeS-->
procedure FIdTCPServerExecute(AThread: TIdPeerThread);
while AThread.Connection.Connected do begin
AThread.Connection.ReadBuffer(Protocol, 1);
if (Protocol=NAK) then
FThread := AThread;
AThread.Synchronize(ProcessNAKPacket);
begin
end;
end;
end;
procedure ProcessNAKPacket;
begin
FThread.Connection.WriteLn('재전송');
end;
<!--CodeE-->
A에서 NAK를 받으면 B라는 곳으로 보내려면
<!--CodeS-->
procedure ProcessNAKPacket;
var
aCount: Integer;
List : TList;
aIp : string;
begin
List := FIdtcpServer.Threads.LockList;
try
for aCount := 0 to List.Count -1 do
begin
try
aIp := TIdPeerThread(List.Items[aCount]).Connection.Socket.Binding.IP;
if aIp='192.168.1.1' then
TIdPeerThread(List.Items[aCount]).Connection.WriteLn('재전송');
except
TIdPeerThread(List.Items[aCount]).Stop;
end;
end;
finally
FIdtcpServer.Threads.UnlockList;
end;
A에서 받아서 A로 전송하면,
<!--CodeS-->
procedure FIdTCPServerExecute(AThread: TIdPeerThread);
while AThread.Connection.Connected do begin
AThread.Connection.ReadBuffer(Protocol, 1);
if (Protocol=NAK) then
FThread := AThread;
AThread.Synchronize(ProcessNAKPacket);
begin
end;
end;
end;
procedure ProcessNAKPacket;
begin
FThread.Connection.WriteLn('재전송');
end;
<!--CodeE-->
A에서 NAK를 받으면 B라는 곳으로 보내려면
<!--CodeS-->
procedure ProcessNAKPacket;
var
aCount: Integer;
List : TList;
aIp : string;
begin
List := FIdtcpServer.Threads.LockList;
try
for aCount := 0 to List.Count -1 do
begin
try
aIp := TIdPeerThread(List.Items[aCount]).Connection.Socket.Binding.IP;
if aIp='192.168.1.1' then
TIdPeerThread(List.Items[aCount]).Connection.WriteLn('재전송');
except
TIdPeerThread(List.Items[aCount]).Stop;
end;
end;
finally
FIdtcpServer.Threads.UnlockList;
end;
end;
<!--CodeE-->
Indy Demo에서 발췌했습니다.
즐거운하루되세요 ^^;