Hi Francois, thank you for your response. I've created the socket inside DoInit, that is an override method of the virtual DoInit of the worker thread. The DoInit method is called inside Execute method, so the socket is created by the thread and its messages are handled by it (try to use GetThreadID inside socket callbacks). As you can see 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. In my example I think that the gui should not interfere with worker thread.
I can't use tcp in my application, I need udp. Any ideas? Thank you, Emanuele Il 26/02/2011 16.29, Francois PIETTE ha scritto: >> I've a problem with udp. >> Often my application detects packet losses. > > At first glance, this is expected with UDP. By construction UDP is an > unreliable transport. > >> In order to systematically reproduce the problem, I've used the >> following configuration. >> I use 2 pc connected with a cross cable. >> The client sends udp numbered packets to the server. >> Packet size is 1460. One packet is sent every 1 ms (about 11 Mbps). >> >> I use wireshark to analyze the traffic on the server machine. >> I see that all the packets arrive on the server, but not inside the >> application. >> >> Packet loss increases if I resize the form, so I've made a worker thread >> in order to manage udp server socket messages, but the problem remains. > > This is "normal". If the application is not able to read UDP packets as > fast as packets are incomming, they are simply dropped. There is no flow > control with UDP. This is how UDP is working. > >> Have you any suggestion to resolve this problem? > > The easiest way is to use TCP which is a reliable protocol, with flow > control, retries and everything needed to make it reliable. > >> Maybe the socket configuration should be changed? > > Won't change anything. > If you still want to use UDP, you may use a dedicated thread to handle > communication and give it a high priority so that it will receive CPU > before the user interface. > > >> I attach the code of server, client and worker thread: > > Sorry no time to read your code. i just browsed quickly and see you > don't create TWSocket in thread's execute method, so all events are > handled by the main thread. This is a flaw in your design, at least. > > -- > 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