LennyKrost 1 Posted Monday at 06:43 PM Hi All, I'm using ICS 8.71. Before upgrading I was using ICS V7 Gold. I have problems iwith UDP server sockets created inside TThread objects. I was using ThreadDetatch and ThreadAttach to link socket queue to thread message queue. Now it seems that this procedure does not work anymore. OnDataAvailable event does not trigger anymore. How could I fix this? Thanks in advance. Mario Share this post Link to post
Remy Lebeau 1643 Posted Monday at 08:32 PM Can you provide the actual code you are having trouble with? Did you set the component's MultiThreaded property to true? Does your thread have a message loop? Share this post Link to post
LennyKrost 1 Posted Monday at 08:57 PM Hi Remy, thanks for your interest. I'm going to explain with the current code. I'm sorry. CleanTalk always repeat me that all code i write here is seen as SPAM and does not post my replies. It's so fristrating. How can I send code snippets? Share this post Link to post
LennyKrost 1 Posted Monday at 08:59 PM This is the function that creates the UDPServerSocket Share this post Link to post
LennyKrost 1 Posted Monday at 09:02 PM And this is the code of Execute method of the thread. This was full working with ICS V7. Now with ICS 8.71 the OnDataAvailable event is not triggered anymore. Share this post Link to post
Remy Lebeau 1643 Posted Tuesday at 04:26 AM (edited) 7 hours ago, LennyKrost said: I'm sorry. CleanTalk always repeat me that all code i write here is seen as SPAM and does not post my replies. Never heard of CleanTalk. Quote How can I send code snippets? Are you putting your code snippets in code blocks (the `</>` button on the editor toolbar)? 7 hours ago, LennyKrost said: This is the function that creates the UDPServerSocket I'm guessing you did not read the ICS documentation. It says: https://wiki.overbyte.eu/wiki/index.php/TWSocketServer Quote Note that TWSocketServer is only usable for incoming TCP connections. Use TWSocket if you need to use UDP. 7 hours ago, LennyKrost said: And this is the code of Execute method of the thread. On a side note: `while PeekMessage() = False do WaitMessage();` is the exact same as calling `GetMessage()` without a loop. Quote This was full working with ICS V7. Now with ICS 8.71 the OnDataAvailable event is not triggered anymore. Makes sense, if you are creating a TCP server socket expecting it to receive UDP traffic. You need a UDP server socket. Edited Tuesday at 04:28 AM by Remy Lebeau Share this post Link to post
LennyKrost 1 Posted Tuesday at 05:48 AM 1 hour ago, Remy Lebeau said: Never heard of CleanTalk. Are you putting your code snippets in code blocks (the `</>` button on the editor toolbar)? I'm guessing you did not read the ICS documentation. It says: https://wiki.overbyte.eu/wiki/index.php/TWSocketServer On a side note: `while PeekMessage() = False do WaitMessage();` is the exact same as calling `GetMessage()` without a loop. Makes sense, if you are creating a TCP server socket expecting it to receive UDP traffic. You need a UDP server socket. Hi Remy. Thanks fior your reply. This code has been working perfectly for at least 10 years. Recently I had to move to most recent ICS componets for Delphi 2007 because TLS 1.0 is not supported by most OF systems. I just had to recompile the project after installing new componets; all things “seemed” to work as before, but it wasn’t. As you can see, in socket creation I set Proto property to “udp” and compiler does not report any warning. I’m going to Office and change TWSocketServer into TWSocket and will per You know if it works. Thanks for the help and suggestions. Regards. Mario. Share this post Link to post
Cristian Peța 122 Posted Tuesday at 07:29 AM 1 hour ago, LennyKrost said: As you can see, in socket creation I set Proto property to “udp” and compiler does not report any warning. It is just a string property. What can compiler complain? But documentation for TWSocketServer says: Quote Proto Protocol used. Must be 'tcp'. Share this post Link to post
Angus Robertson 663 Posted Tuesday at 07:58 AM Tour main problem is using TWSocketServer for UDP, it does not work since UDP has no connections or clients. The component might have worked with UDP 20 years ago, but not today. For UDP you just use TWSocket. Or use the newer TIcsIpStrmLog component with LogProtocol as logprotUdpServer which is much easier to use, look at the Snipptets sample for very simple examples. Angus Share this post Link to post
LennyKrost 1 Posted Tuesday at 08:34 AM Hi all, thanks for all suggestions and advice. Problem was solved just maintaining exactly the same code written years ago with old ICS version but with only one change. This change, as suggested by Angus and Remy, was to replace the "TWSocketServer" socket declaration with simply "TWSocket". UDP Server started working again. Next time I'll read the whole documentation before making updates. 😄 1 Share this post Link to post