C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[47314] [질문]인디서버가 시간이 지나면 죽습니다.
하안인 [hurco] 1565 읽음    2006-12-05 18:30
인디서버가 시간이 지나면 죽어 버려서
몇일째 이것저것 바꿔 보아도 똑같은 현상입니다.

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();
  }

}

위와 같이 처리했는데 ....
어디서 에러가 발생되는 지 도무지 모르겠습니다.

답변부탁드립니다.

+ -

관련 글 리스트
47314 [질문]인디서버가 시간이 지나면 죽습니다. 하안인 1565 2006/12/05
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.