|
코드의 앞 뒤 전후를 살펴보건데
GetNextRequest 라고 Buffer 에 처리할 메세지를 받아오는 함수를
thread-safe 하게 작성하라는 거 같은데요...
역삼골 님이 쓰신 글 :
: TWinSocketStream Write() Method 셈플예제에 보면
: GetNextRequest() <- GetNextRequest must be a thread-safe method
: 라는 부분이 있는데요.
: C Builder에서는 없는 함수네요.
: 설명 좀 부탁드립니다.
:
: 메모리증가하는것 때문에 검색하고 있는데요.
: 잘 안되네요.
: 저만 그런가요..--;;
:
: 아래 소소는 C Builder 도움말에서 가져왔습니다.
:
:
:
: This example shows the execute method of a thread used to send requests to a server over a socket connection:
:
: void __fastcall TMyClientThread::Execute()
: {
: // create a TWinSocketStream for reading and writing
: TWinSocketStream *pStream = new TWinSocketStream(ClientSocket1->Socket, 60000);
: try
: {
: // fetch and process commands until the connection or thread is terminated
: while (!Terminated && ClientSocket1->Active)
: {
: try
: {
: char buffer[10];
: GetNextRequest(buffer); // GetNextRequest must be a thread-safe method
:
: // write the request to the server
: pStream->Write(buffer, strlen(buffer) + 1);
: // continue the communication (eg read a response from the server)
: ...
: }
: catch (Exception &E)
: {
: if (!E.ClassNameIs("EAbort"))
: Synchronize(HandleThreadException()); // you must write HandleThreadException
: }
: }
: }
: __finally
: {
: delete pStream;
: }
: }
|