기본 서버소켓은 성능에 문제가 있습니다.
그래서 RS2007에서는 퇴출된 컴포넌트입니다.
인디를 쓰세요.
역삼골 님이 쓰신 글 :
: 클라이언트 쓰래드 Terminate가 제대로 않되서
: 4000개에서 멈췄나봅니다.
:
: 항상 감사합니다.
: 즐거운 주말 되세요. ^^
:
: 역삼골 님이 쓰신 글 :
: : 저 같은 경우에는
: : 동시 접속 100유저로 테스트 하고 있습니다.
: : 즉, 동시에 100개 이상은 쓰래드가 생성되지 않는데요.
: :
: : 즉, 쓰래도 생성하고 죽이고 생성하고 죽이고 ...반복합니다.
: : ActiveThread를 봐도 평균 50개 정도입니다.
: :
: : 장성호님 팁에 있는데로라면
: : 최대 2000건(팁 내용대로..) 이상은 쓰래드가 생성되지 않는건가요?
: :
: : 전 동시에 2000건 생성하는건 아닙니다.
: :
: : 항상 답변 고맙습니다. ^^
: :
: : 장성호 님이 쓰신 글 :
: : : 아래 팁을 참조하세요
: : :
: : :
http://cbuilder.borlandforum.com/impboard/impboard.dll?action=read&db=bcb_tip&no=186
: : :
: : : 그럼..
: : :
: : : 역삼골 님이 쓰신 글 :
: : : : 왜 4천건정도 접속 후에 접속이 않됩니다.
: : : : 서버 소켓을 클로즈하고 접속하면 다시 또 접속은 되지만 또 4천 후면 접속이 않되네요.
: : : : 왜 그런지 모르겠습니다.
: : : :
: : : : 테스트용 프로그램을 만들어서 계속 접속하고 해제하고 반복해서 돌리고 있습니다.
: : : :
: : : : //---------------------------------------------------------------------------
: : : : //Socket Thread Create Event
: : : : //---------------------------------------------------------------------------
: : : : void __fastcall Tfkmsmain::AuthServerSocketGetThread(TObject *Sender,
: : : : TServerClientWinSocket *ClientSocket,
: : : : TServerClientThread *&SocketThread)
: : : : {
: : : : try
: : : : {
: : : : //TServerClientThread 를 생성
: : : : SocketThread = new TServerSocketThread(false, ClientSocket);
: : : : }
: : : : //Excetion process
: : : : __except(EXCEPTION_EXECUTE_HANDLER)
: : : : {
: : : : }
: : : : }
: : : :
: : : : //---------------------------------------------------------------------------
: : : : //Thread Start Event
: : : : //---------------------------------------------------------------------------
: : : : void __fastcall Tfkmsmain::AuthServerSocketThreadStart(TObject *Sender,
: : : : TServerClientThread *Thread)
: : : : {
: : : : //Thread Object, Socket handle Insert
: : : : ThreadObjectCombo->Items->AddObject(IntToStr(Thread->ThreadID), Thread);
: : : : Label1->Caption = IntToStr(StrToInt(Label1->Caption) + 1);
: : : : }
: : : :
: : : : //---------------------------------------------------------------------------
: : : : //Socket Thread End Event
: : : : //---------------------------------------------------------------------------
: : : : void __fastcall Tfkmsmain::AuthServerSocketThreadEnd(TObject *Sender,
: : : : TServerClientThread *Thread)
: : : : {
: : : : Thread->Terminate();
: : : :
: : : : //Close Socket Handle Search
: : : : int nObjectIndex = ThreadObjectCombo->Items->IndexOf(IntToStr(Thread->ThreadID));
: : : : if (nObjectIndex >= 0) ThreadObjectCombo->Items->Delete(nObjectIndex);
: : : : Label2->Caption = IntToStr(StrToInt(Label2->Caption) + 2);
: : : : }
: : : :
: : : : void __fastcall TServerSocketThread::ClientExecute(void)
: : : : {
: : : : TWinSocketStream *pStream = 0;
: : : : BYTE bReceiveBuffer[65536] = {0x00,},
: : : : bSendBuffer[65536] = {0x00,};
: : : : long nReceiveBufferLen = 0,
: : : : nSendBufferLen = 0;
: : : : long nWaitingTime = 0;
: : : : SYSTEM_WORK_INFO tSystemWorkInfo;
: : : : int nWaitTimeOut = 60000; //ms
: : : : bool bFirstMsgRcv = true;
: : : :
: : : : //Socket Handle save
: : : : nSocketHandle = ClientSocket->SocketHandle;
: : : :
: : : : //System Work Information Structure Reset
: : : : memset((char*)&tSystemWorkInfo, 0x00, sizeof(SYSTEM_WORK_INFO));
: : : :
: : : : try
: : : : {
: : : : //TWinSocketStream is a stream that provides services which allow
: : : : //applications to read from or write to socket connections.
: : : : pStream = new TWinSocketStream(ClientSocket, 60000);
: : : :
: : : : //Waiting condition : not Time Out, not Terminate, not Socket Disconnect
: : : : while(!Terminated && ClientSocket->Connected) //nWaitingTime < nSocketTimeOut &&
: : : : {
: : : : //Waits up to TimeOut milliseconds for the socket connection to be ready to transfer data.
: : : : //Application->ProcessMessages();
: : : : if(pStream->WaitForData(nWaitTimeOut))
: : : : {
: : : : //
: : : : //Thread Blocking mode then read(void*,int) function use
: : : : //
: : : : //Reads up to Count bytes from the socket connection into Buffer.
: : : : if (Terminated || !ClientSocket->Connected) break;
: : : :
: : : : try
: : : : {
: : : : //Read Buffer
: : : : memset(bReceiveBuffer, 0, sizeof(bReceiveBuffer));
: : : : nReceiveBufferLen = pStream->Read(bReceiveBuffer, sizeof(bReceiveBuffer));
: : : : }//try
: : : : catch (Exception &E)
: : : : {
: : : : HandleException();
: : : : }
: : : : if (nReceiveBufferLen == 0) break;
: : : : else
: : : : {
: : : : //CHIP Process Request
: : : : nWaitingTime = 0;
: : : : memset(bSendBuffer, 0x00, sizeof(bSendBuffer));
: : : : memset(tSystemWorkInfo.cWorkResult, 0x00, sizeof(tSystemWorkInfo.cWorkResult));
: : : : epassclass->InferfaceMain(&tSystemWorkInfo, bReceiveBuffer, nReceiveBufferLen, bSendBuffer, &nSendBufferLen);
: : : :
: : : : //Client Socket Send Buffer
: : : : pStream->Write(bSendBuffer, nSendBufferLen);
: : : : }
: : : : }
: : : :
: : : : //Delay time
: : : : Sleep(10);
: : : : }
: : : :
: : : : //Client Socket Close
: : : : ClientSocket->Close();
: : : :
: : : : //Stream free
: : : : delete pStream;
: : : : }
: : : : //Excetion process
: : : : __except(EXCEPTION_EXECUTE_HANDLER)
: : : : {
: : : : //Client Socket Disconnect
: : : : ClientSocket->Close();
: : : :
: : : : //Stream free
: : : : delete pStream;
: : : : }
: : : : }