Brief glance at the code - it looks good to me, except for the FD_SET(...) line which seems to have an extra ) after the sock variable.<div><br></div><div>I would uncomment the line you have commented. Its likely that if you run this program after amqp_producer.c program, that a frame or two is cached and that the result of amqp_frames_enqueued() is returning true<br>
<br>Also check with the management plugin see if there is a message in the queue ready to be consumed.</div><div><br></div><div>-Alan</div><div><br><div class="gmail_quote">On Thu, Feb 16, 2012 at 1:08 PM, Brett Cameron <span dir="ltr">&lt;<a href="mailto:brett.r.cameron@gmail.com">brett.r.cameron@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Arun,<div><br></div><div>A couple of random early in the�morning�pre-caffeine�thoughts: is sock set to non-blocking? What&#39;s the errno value after the select() returns?</div>
<span class="HOEnZb"><font color="#888888"><div><br></div><div>Brett</div></font></span><div class="HOEnZb"><div class="h5"><div><br><div>
<br><div class="gmail_quote">On Fri, Feb 17, 2012 at 6:14 AM, Arun Chandrasekaran <span dir="ltr">&lt;<a href="mailto:visionofarun@gmail.com" target="_blank">visionofarun@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Thanks for reply Alan.<br><br>I modified the amqp_consumer.c sample code to simulate the non-blocking behaviour as you mentioned.<br><br><span style="font-family:courier new,monospace">��� /* if (!amqp_frames_enqueued(conn) &amp;&amp; !amqp_data_in_buffer(conn)) { */</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">��� if (1) {</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">������ int sock = amqp_get_sockfd(conn);</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">������ printf(&quot;socket: %d\n&quot;, sock);</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">������ /* Watch socket fd to see when it has input. */</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">������ fd_set read_flags;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">������ FD_ZERO(&amp;read_flags);</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">������ FD_SET(sock), &amp;read_flags);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">������ int ret = 0;</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">������ do {</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">��������� struct timeval timeout;</span><br style="font-family:courier new,monospace">


<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">��������� /* Wait upto a second. */</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">��������� timeout.tv_sec = 1;</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">��������� timeout.tv_usec = 0;</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">��������� ret = select(sock+1, &amp;read_flags, NULL, NULL, &amp;timeout);</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">��������� if (ret == -1)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">������������ printf(&quot;select: %s\n&quot;, strerror(errno));</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">��������� else if (ret == 0)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">������������ printf(&quot;select timedout\n&quot;);</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">��������� if (FD_ISSET(sock, &amp;read_flags)) {</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">������������ printf(&quot;Flag is set\n&quot;);</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">��������� }</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">������ } while (ret == 0);</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">��� }</span><br><br>But this always results in a timeout. Any idea where I might be going wrong? I have commented the first two checks that you mentioned just for sake of clarity on select().<span><font color="#888888"><br>


<br>-Arun<br>
</font></span></blockquote></div><br></div></div>
</div></div></blockquote></div><br></div>