|
void __fastcall TForm1::ClientToSend(String toIP,String Msg)
{
TThreadList* thdlist = opCommServ->Threads;
void *aa;
String ss;
try
{
TList* list = thdlist->LockList();
TIdPeerThread* thd;
TIdTCPServerConnection* con;
for(int i = 0; i < list->Count; i++)
{
thd = (TIdPeerThread*)list->Items[i];
ss = thd->Connection->Socket->Binding->PeerIP;
if(ss != toIP)
continue;
// MsgAdd(ss );
con = thd->Connection;
con->WriteLn(ipMsg);
MsgAdd(ss+String("==>>")+ipMsg);
}
}
__finally
{
thdlist->UnlockList();
}
}
위와 같이 클라이언트에 메시지 전송프로그램을 작성 했는데요..
클라이어언트에 메시지를 보내려고 할때 클라이언트에서 소켓을 닫으면
어떻게 될까요...
위의 소스는 현재 연결되어 있는 ip를 찾아서 연결되어 있으면 보내라고 했는데...
클라이언트에서는 어떤 메시지를 보내려고 할때 접속을 중지한후 재접속한후 메시지를 보내느데...
이것이 충돌날 수 있나요... 위에서 서치하는 동안. ....블럭이 발생될수 있나해서요..
서버쪽이 다운되는 현상이 발생되서....
참, 그리고 클라이언트에서 서버쪽이 끊겼는지 알려면 어떻게 해야 하나요..
|