Attaching UDP Message to Interrupts

hello every one!
I am doing Home automation project. in which i am using UDP as well as MQTT, when MQTT got disconnected, controller do a try for re-connection but this retry takes about 5 second and at that time when message from UDP comes I receive it after 5 second. so here i want to attach UDP message to interrupt , so I should receive it instantly. but I don't have any idea to attach programming instructions to interrupt. kindly help me some one. thanks in advance

An interrupt is an event that occurs, like the mailman ringing the doorbell to tell you that you have a package to sign for.

Exactly what event will occur for which the proper response is to read a UDP package?

Aisha_khan656:
controller do a try for re-connection but this retry takes about 5 second and at that time when message from UDP comes I receive it after 5 second. so here i want to attach UDP message to interrupt , so I should receive it instantly.

Are you {A} trying to make the re-connection instantly, rather than have a 5 second wait?

OR {B} do you want to be notified immediately when the connection is made after the 5 second wait?

There is certainly no need to use an interrupt in case {B}.

And as you have not said what is the cause of the 5 second delay I can't say whether an interrupt could help to reduce the delay - but I very much doubt if it would be of any value.

Interrupts are generally for detecting things that only last for a brief period measured in microseconds.

...R