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) && !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("socket: %d\n", 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(&read_flags);</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> FD_SET(sock), &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, &read_flags, NULL, NULL, &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("select: %s\n", 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("select timedout\n");</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> if (FD_ISSET(sock, &read_flags)) {</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> printf("Flag is set\n");</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().<br>
<br>-Arun<br>