Jump to content
LennyKrost

ICS 8.71 UDP ServerScoket inside a Thread

Recommended Posts

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

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

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

And this is the code of Execute method of the thread.

image.thumb.png.d0b4afc9cbbb3f1fa14c174e0e889ffd.png

image.thumb.png.3df8fe040ff615513b69ea5469ea69aa.png

 

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
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 by Remy Lebeau

Share this post


Link to post
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
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

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

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. 😄

 

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×