<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Safe A-Sync Socket Operations</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51034/safe-a-sync-socket-operations</link><description>Hi, 
 I was wondering if I could get some guidance (or directed to some documentation on the subject) with regards to what socket operations are safe to do in a-sync timer callback. 
 Right now I am trying the following: 
 
 I setup a UDP socket listener</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 16 Aug 2019 11:39:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51034/safe-a-sync-socket-operations" /><item><title>RE: Safe A-Sync Socket Operations</title><link>https://devzone.nordicsemi.com/thread/204484?ContentTypeID=1</link><pubDate>Fri, 16 Aug 2019 11:39:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d913e17d-5269-4175-837b-5872a950be0c</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]If I try and do step 3 asynchronously, within the timer handler, it fails.[/quote]
&lt;p&gt;K_TIMER, right? Those will execute in interrupt context, so I would not recommend&amp;nbsp;calling functions directly from the k_timer_handler, as some functions (like taking a semaphore) will generate a fault condition if called from interrupt context, but instead use a work queue (&lt;a href="https://docs.zephyrproject.org/1.9.0/kernel/threads/workqueues.html"&gt;https://docs.zephyrproject.org/1.9.0/kernel/threads/workqueues.html&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;This would be similar in behavior as your current workaround (setting a flag).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>