Jump to content
DavidS

ReceiveFrom blocking

Recommended Posts

Using old TWSocket 5.31

 

Using  .Receive  in an OnDataAvailable procedure works great.

When I try .ReceiveFrom, it hangs the code and has to be killed with task manager.

Is there any way of making .ReceiveFrom non blocking?

 

Thanks for any help.

Share this post


Link to post

TWSocket 5.31 goes back 11 years, but ReceiveFrom is essentially the same today.  However it is no longer supported. 

 

ReceiveFrom is async and returns immediately, it is normally used for UDP only so you know where the data has come from. it is widely used today and does not cause applications to lock up.  It sound like you have a continuous loop reading data without any error handling. 

 

Angus

 

Share this post


Link to post

Thank you for your reply.
Yes it is for UDP messages.
Currently using .Receive inside an OnDataAvailable procedure
and it works fine, retrieving the message contents.
This is obviously only called when data is available.
If .Receive is simply replaced with .ReceiveFrom,
and a message arrives, then execution disappears into
TWSocket code and never returns.
Putting it in a try except does not help.
Maybe there is another way I can retrieve the senders
address?

 

Share this post


Link to post

No other way to get the remote UDP address, since there is no connection.  All UDP applications use ReceiveFrom, it has always worked. 

Suggest you upgrade to a modern supported version of ICS, but you will need to change your application, all the unit names changed 10 years ago.

 

Angus

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

×