Thread View: borland.public.cppbuilder.internet.socket
2 messages
2 total messages
Started by syncopator
Tue, 29 Jan 2008 21:29
50% datagram drop with Indy
Author: syncopator
Date: Tue, 29 Jan 2008 21:29
Date: Tue, 29 Jan 2008 21:29
39 lines
2383 bytes
2383 bytes
I'm reading UDP datagrams from my camera over a closed network. The camera
is connected directly to my network card with a crossover cable and is on a
static IP. It sends 1000 datagrams per second, each one is 1.3 KB. So it's
roughly 13% of the 100T.
I'm using the UDP server from Indy 8, and receiving 50% of the packets. The
data is of the correct size and is valid. I'm running the server in a high
priority thread and have stripped away all the processing.
I originally implemented the code with FastNet, and I was getting 2% drops.
Any help would be greatly appreciated.
DWORD WINAPI ThreadFunc(LPVOID Param) {
HANDLE MainWnd (Param);
char Buffer[8192];
int i,j, port, Len;
while (true){
Len=Form1->Server->ReceiveBuffer(Buffer,8192) ;
dcnt++;
pcnt+=Len;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
DWORD Id;
Thread= CreateThread(0,0,ThreadFunc,
Form1->Handle,CREATE_SUSPENDED,&Id);
if(!Thread){
ShowMessage("Error Creating Thread");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
SetPriorityClass( Thread,REALTIME_PRIORITY_CLASS );
ResumeThread(Thread);
Timer1->Enabled = true;
}
Re: 50% datagram drop with Indy
Author: Remy Lebeau (TeamB)
Date: Wed, 30 Jan 2008 06:45
Date: Wed, 30 Jan 2008 06:45
24 lines
1849 bytes
1849 bytes
"syncopator" <bobback@inbox.com> wrote in message news:479f9abe$1@newsgroups.borland.com... > I'm using the UDP server from Indy 8, and receiving 50% of the packets. That is because you are not taking into account that TIdUDPServer runs its own threads internally for receiving packets. So you are reading from the same socket in multiple threads simultaneously. Some data is going to be received in your thread, and some data in TIdUDPServer's threads. > I'm running the server in a high priority thread Whatever you do to the thread that owns the TIdUDPServer instance will not apply to the threads that TIdUDPServer creates internally. > Len=Form1->Server->ReceiveBuffer(Buffer,8192) ; If you are going to do that in your own thread, then TIdUDPServer is the wrong component to use. Otherwise, you should let TIdUDPServer handle the threading for you, and you can simply adjust its priority as needed. Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads