|
안녕하세요.
늘 질문만 하고 갑니다.
Indy 9을 이용하여 TCP/IP 서버와 클라이언트를 구성하였습니다.
클라이언에 멀티 미디어 타이어를 이용하여 50 ms 마다
writebuffer을 이용하여 정보를 송신하려고 합니다.
반복 없이 한 번만 작업을 수행했을 때는 아무 문제 없이 데이터가 전송되는 것을 확인 했습니다.
타이머를 적용할 경우,
첫 번째 송신 데이터만 정상적으로 서버에서 수신되고
그 이후에 송신되는 데이터는 어디로 갔는지 수신을 못하고 있습니다.
코드 첨부하오니
여러 고수님들의 좋으신 의견을 기다라겠습니다.
/////////// 서버 //////////
void __fastcall TForm2::IdTCPServer1Execute(TIdPeerThread *AThread)
{
float TajeX;
structure_b *rMsg = new structure_b; // 송수신용 구조체
AThread->Connection->ReadBuffer((structure_b*)rMsg,sizeof(structure_b));
TajeX=rMsg[0].Ruder;
Memo1->Lines->Add(TajeX);
}
/////////// 클라이언트 //////////
void __fastcall TForm2::Button1Click(TObject *Sender)
{
IdTCPClient1->Connect();
DWORD StartMMTime, EndMMTime; // 멀티미디어 타이머 인자
double d,d2,duration;
int i=0;
AnsiString stTemp;
d=50.0;// interval
StartMMTime = timeGetTime();
for (; ; ) {
EndMMTime = timeGetTime();
duration=(double)(EndMMTime - StartMMTime);
if (fabs(duration-d)<0.5) {
i++;
structure_b *sMsg = new structure_b;// 송수신용 구조체
sMsg[i].Ruder = (float) i;
sMsg[i].Depth = (float) (2*i);
sMsg[i].Event = Test;
sMsg[i].Time = Now().FormatString(("hh:nn:ss.zzz"));
IdTCPClient1->WriteBuffer((structure_b*)sMsg,sizeof(structure_b),false);
delete sMsg;
d=d+50;
Memo1->Lines->Add(i);
}
if (d>200) {
break;
}
}
}
감사합니다.
|