안녕하세요 델파이 초보자 입니다.
indy tcpserver tcpclient 를 사용해서 프로그램을 작업했습니다.
우선 클라이언트가 접속시에는 ip를 알수 있었는데 특정클라이언트가 강제종료 및 접속종료시 ip를 알 수 있는 방법을 몰라서 부탁드리고자 합니다.
예)
// 3-1.접속시 실행
procedure Tfrmmain.TCPServerExecute(AThread: TIdPeerThread);
var
msg : String ;
begin
while AThread.Connection.Connected do
begin
msg := AThread.Connection.ReadLn;
ListBox1.Items.Add(msg);
Broadcast(msg); // 쓰레드 처리 프로시저
end;
end;
// 3-2.접속시 클라이언트 보여주기 ( ip 보임 )
procedure Tfrmmain.TCPServerConnect(AThread: TIdPeerThread);
var
i : integer;
c_list, c_connected : string;
begin
c_connected := AThread.Connection.Binding.PeerIP; // 접속된 클라이언트 ip
for i := 0 to lv_clnt_list.Items.Count -1 do
begin
c_list := lv_clnt_list.Items.Item[i].SubItems[0];
if c_connected = c_list then
begin
ListBox1.Items.Add(c_connected+'와 접속되었습니다.');
lv_clnt_list.Items.Item[i].SubItemImages[2] := 7;
lv_clnt_list.Items.Item[i].SubItems[2] := '연결';
break;
end;
end;
end;
// 3-3.접속끊어진 클라이언트 보여주기 (* ip가 안나옴 )
procedure Tfrmmain.TCPServerDisconnect(AThread: TIdPeerThread);
var
i : integer;
c_disconnect : string;
begin
c_disconnect := AThread.Connection.Binding.PeerIP;
ListBox1.Items.Add(c_disconnect+'와 접속이 끊겼습니다.');
end;
이상입니다.
부탁드립니다.