Hi,
I need to use udp because my application is an h323/sip endpoint.
RTP uses udp sockets to transmit/receive audio/video data.
RTCP can be used to manage packet loss.

But in this case packets are not lost by the network. If I use wireshark
I can see all the packets.

I think that there is a problem in my code. I know that gui messages can
interfere with socket messages. So I've created a worker thread that
manage socket in its own message loop.

Could be the problem in the way I create/use the message loop in worker
thread?
This is the execute method (DoInit create the socket):

procedure TWorkerThread.Execute;
begin
  DoInit;
  MessageLoop;
end;

Inside the message loop method, I allocate fThreadHandle and then begin
dispatch messages.

procedure TWorkerThread.MessageLoop;
var
  lMsg:TMsg;
begin
  fThreadHandle:=AllocateHWnd(ThreadWndProc);
  PeekMessage(lMsg,0,0,0,PM_NOREMOVE);
  SetEvent(fResumeEvent);
  //GetMessage return false on WM_QUIT
  while (GetMessage(lMsg,0,0,0))and(not self.Terminated) do
  begin
    TranslateMessage(lMsg);
    DispatchMessage(lMsg);
  end;
  DeallocateHWnd(fThreadHandle);
end;

The DoInit method is called before AllocateHWnd, so the socket is
created before. Could be here the problem?

It seems that the thread is not fast enought to elaborate socket
messages. Or that the gui slow the worker thread in some way. If I call
GetCurrentThreadID inside the DataAvailable the result is the id of the
worker thread.
The only thing done inside the DataAvailable callback is check packet
number.
The cpu is used about 12%.

I've tried to set the process priority (thank you Angus), but nothig
changes.

What kind of performance do you reach using udp sockets? I think that my
performance are not satisfactory.

Thank you for your help.

Emanuele




Il 26/02/2011 21.15, Francois PIETTE ha scritto:
>> As you can see
> 
> Sorry, no time to examine it in details.
> Priority is given to my business customers...
> 
>> in my code I've also try to set tpTimeCritical to thread
>> priority, but without any success.
> 
>> The worker thread check if expected packet number (first four bytes)
>> corresponds to expected packet number.
>> I can't use tcp in my application, I need udp.
> 
> You software, when using UDP, must be preapred to packet loss, duplicate
> packets and packet in incorrect order. If it is not possible in your
> case, you can't use UDP. UDP is a simple packet protocol with only best
> delivery effort. This is not an issue with ICS, it is simple how UDP works.
> 
>> In my example I think that the gui should not interfere with worker
>> thread.
>> Any ideas?
> 
> If you loose packet, then your software, or the whole computer is not
> fast enough to handle all packets as they are delivered. Buy a faster
> computer or optimize the software.
> 
> Of course also check if your network card is OK and setup for 100 Mbps.
> 
>> I can't use tcp in my application, I need udp.
> 
> Why do you think you must use UDP ?
> Why isn't TCP good for you ?
> 
> -- 
> francois.pie...@overbyte.be
> The author of the freeware multi-tier middleware MidWare
> The author of the freeware Internet Component Suite (ICS)
> http://www.overbyte.be
> 
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be

-- 
Ing. Emanuele Bizzarri
Software Development Department
e-works s.r.l.
41011 - Campogalliano - Modena - Italy
tel. +39 059 2929081 int. 23
fax +39 059 2925035

e-mail: e.bizza...@e-works.it - http://www.e-works.it
---------------------------------------------------------------------
La presente comunicazione, che potrebbe contenere informazioni riservate
e/o protette da segreto professionale, è indirizzata esclusivamente ai
destinatari della medesima qui indicati. Le opinioni, le conclusioni e
le altre informazioni qui contenute, che non siano relative alla nostra
attività caratteristica, devono essere considerate come non inviate né
avvalorate da noi. Tutti i pareri e le informazioni qui contenuti sono
soggetti ai termini ed alle condizioni previsti dagli accordi che
regolano il nostro rapporto con il cliente. Nel caso in cui abbiate
ricevuto per errore la presente comunicazione, vogliate cortesemente
darcene immediata notizia, rispondendo a questo stesso indirizzo di
e-mail, e poi procedere alla cancellazione di questo messaggio dal
Vostro sistema. E' strettamente proibito e potrebbe essere fonte di
violazione di legge qualsiasi uso, comunicazione, copia o diffusione dei
contenuti di questa comunicazione da parte di chi la abbia ricevuta per
errore o in violazione degli scopi della presente.
---------------------------------------------------------------------
This communication, that may contain confidential and/or legally
privileged information, is intended solely for the use of the intended
addressees. Opinions, conclusions and other information contained in
this message, that do not relate to the official business of this firm,
shall be considered as not given or endorsed by it. Every opinion or
advice contained in this communication is subject to the terms and
conditions provided by the agreement governing the engagement with such
a client. If you have received this communication in error, please
notify us immediately by responding to this email and then delete it
from your system. Any use, disclosure, copying or distribution of the
contents of this communication by a not-intended recipient or in
violation of the purposes of this communication is strictly prohibited
and may be unlawful.

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to