|
1.UPDCleint가 time out을 내는 경우는 어떤 경우인가요? - 아래와 같이 코딩했을때..
(UDP 서버는 분명히 살아 있다고 가정하고. 네트웍은 정상이라고 가정합니다.... )
처음 몇시간은 timeout이 나는 경우가 없는데... 좀 시간이 지나면... (4-5시간 이상 )
한번 timeout 이 발생하면... 서버를 죽였다 살리기 전에는 계속 timeout 이 납니다..
IdUDPClient1 콤포넌트가 timeout 내는 경우의 이유를 알고 싶습니다...
*)단 아래의 UPD server는 tray에서 돌고 있는 프로그램입니다..
//UPD client side..
//아래의 timer는 약 10초에 한번씩 발생하는 타이머 입니다.
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
char sendBuf[100];
SYSTEMTIME t;
GetLocalTime(&t);
AnsiString strReceiveString,msg;
int nLen=sprintf(sendBuf,"sending message - %04d-%02d-%02d %02d:%02d:%02d",
t.wYear, t.wMonth, t.wDay, t.wHour , t.wMinute , t.wSecond );
IdUDPClient1->ReceiveTimeout=2000;
IdUDPClient1->Host="192.168.1.5";
IdUDPClient1->Port=4321;
IdUDPClient1->SendBuffer(sendBuf, nLen);
memo->Lines->Add(sendBuf);
strReceiveString = IdUDPClient1->ReceiveString();
if( strReceiveString.IsEmpty()) {
msg.sprintf ("\t<==[time out] - %s\n" , sendBuf);
memo->Lines->Add(msg);
}
else {
msg.sprintf ("\t<==[%s]\n", strReceiveString);
memo->Lines->Add(msg);
}
}
//UDP server side..
//192.168.1.5의 ip를 가진 장비의의 tray영역에서 실행되고 있습니다..
void __fastcall TFormMain::IdUDPServer1UDPRead(TObject *Sender,
TStream *AData, TIdSocketHandle *ABinding)
{
AnsiString rbuf , sendBuf;
char buf[200];;
AData->ReadBuffer(buf, AData->Size);
buf[AData->Size] = '\0';
rbuf=buf;
if(!rbuf.IsEmpty()){
try{
memo->Lines->Add(rbuf);
sendBuf= rbuf + ": OK";
ABinding->SendTo(ABinding->PeerIP, ABinding->PeerPort, sendBuf.c_str(), sendBuf.Length());
}
catch(EIdSocketError &e)
{
AnsiString msg;
msg.sprintf("socket excption ...");
memo->Lines->Add(msg);
}
catch(Exception &e ){
Application->ShowException( &e );
}
}
}
2.dUDPServer1의 ThreadEvent가 false일때와 , true 일때의 차이점이 무엇인가요?
|