|
인디서버가 시간이 지나면 죽어 버려서
몇일째 이것저것 바꿔 보아도 똑같은 현상입니다.
Read 하는 부분.....
void __fastcall TForm1::opCommServExecute(TIdPeerThread *AThread)
{
String strLine;
String strTemp;
try
{
try
{
if(AThread->Terminated || !AThread->Connection->Connected())
{
MsgAdd("Athread Stopped... Terminated");
return;
}
// if( AThread->Stopped || AThread->Terminated ) return;
//Application->ProcessMessages();
//if(AThread->Terminated)
// return;
// AThread->Connection->ReadTimeout = 100;
if(AThread->Connection->ClosedGracefully)
return;
strLine = AThread->Connection->ReadLn();
// strLine = AThread->Connection->ReadLn(EOL,5000);
if(AThread->Terminated || !AThread->Connection->Connected())
{
MsgAdd("Athread Stopped... Terminated");
return;
}
if(strLine.IsEmpty())
{
// MsgAdd("strLine Empty");
return;
}
//AThread->Synchronize(updateclient);
EnterCriticalSection(&CS);
strTemp = AThread->Connection->Socket->Binding->PeerIP+String("==<<")+strLine;
MsgAdd(strTemp);
// MsgAdd( AThread->Connection->Socket->Binding->PeerIP+String("==<<")+strTemp );
if( IPManager( AThread->Connection->Socket->Binding->PeerIP, 3) != 1)
{
MsgAdd( AThread->Connection->Socket->Binding->PeerIP+String("==<<IP가 존재하지 않아 추가함"));
IPManager( AThread->Connection->Socket->Binding->PeerIP, 1);
}
//udp->SendBuffer(strLine.c_str(), strLine.Length()+1,strLine.Length()+1);
if(strLine.SubString(1,7) != "CONNECT")
ListBox3->Items->Add(strLine);
LeaveCriticalSection(&CS);
}
catch (const Exception& e)
{
Except(String("OPCOMMSERV==>")+AThread->Connection->Socket->Binding->PeerIP+e.Message);
// AThread->Connection->DisconnectSocket();
throw;
}
catch (...)
{
Except("-- Unknown Exception(OnExecute)");
throw;
}
}
__finally
{
// MsgAdd("Excute...Close");
//AThread->Connection->Disconnect();
}
}
클라이언트로 메시지 전송루틴
void __fastcall TForm1::ClientToSend(String toIP,String ipMsg)
{
TThreadList* thdlist = opCommServ->Threads;
void *aa;
int n;
String ss;
try
{
try
{
TList* list = thdlist->LockList();
TIdPeerThread* thd;
TIdTCPServerConnection* con;
n = 0;
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;
n = 1;
con->WriteLn(ipMsg);
MsgAdd(ss+String("==>>")+ipMsg);
}
if(n == 0)
{
MsgAdd(toIP+String("-Fail=>>")+ipMsg);
Except(String("CTS No-")+toIP+ipMsg);
}
}
catch(Exception &e)
{
Except(String("ClientToSend-")+toIP+e.Message);
}
catch(...)
{
throw;
}
}
__finally
{
thdlist->UnlockList();
}
}
위와 같이 처리했는데 ....
어디서 에러가 발생되는 지 도무지 모르겠습니다.
답변부탁드립니다.
|