× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thanks Scott. I got my program changed to use non-blocking at all time and
use select() to detect data as suggested by Albert.

Thank you all for help


"Scott Klement" <midrange-l@xxxxxxxxxxxxxxxx> wrote in message
news:mailman.26066.1296251280.2702.midrange-l@xxxxxxxxxxxx...
Hello,

to switch a socket to non-blocking mode:

flags = fcntl(mySock: F_GETFL);
flags = %bitor(flags: O_NONBLOCK);
fcntl(mySock: F_SETFL: flags);

to switch it back to blocking:

flags = fcntl(mySock: F_GETFL);
if %bitand(flags: O_NONBLOCK) <> 0;
flags -= O_NONBLOCK;
endif;
fcntl(mySock: F_SETFL: flags);

But, I'm not a huge fan of switching back & forth between blocking &
non-blocking. I suggest putting it into nonblocking mode, and leaving it
there. Do everything in non-blocking mode.


On 1/28/2011 2:37 PM, hockchai Lim wrote:
Unfortunately, there is no transaction ID in the respond. Half of the
time,
I'll only get a respond of **, which indicates successful, or ? , which
indicates failure.

Scott,
I did a quick glance at your socket tutorial (great stuffs) doc and see
some
examples on how to set non-blocking at the socket descriptor level (which
I
assuming will effect all call to recv()). I don't see example on how to
set
non-blocking on just a specify recv() call.

if my currently recv() code looks like below:
recv(conn.hostSock :%addr(myBlockData) :%size(myBlockData) :0);

would it be correct for the non-blocking mode recv() code to be like
below:
recv(conn.hostSock :%addr(myBlockData) :%size(myBlockData) :128);

thanks.



"Scott Klement"<midrange-l@xxxxxxxxxxxxxxxx> wrote in message
news:mailman.26037.1296245754.2702.midrange-l@xxxxxxxxxxxx...
Hmmm... is there any way to detect that a message is a duplicate? For
example, does each message have a transaction ID number in it, so that a
duplicate could be detected (same ID occurs twice).

If so, I'd suggest leaving the message in the buffer, and when you
handle
the response for the next transaction, just read and ignore any
transaction ids you've already handled.

That way, you don't end up waiting for duplicated data that might never
come.

But, if there's no way to detect whether you have a duplicate or not,
and
every second counts in this app, then I'd suggest trying to fix the
problem at it's source.


On 1/28/2011 11:54 AM, hockchai Lim wrote:
The reason I want to use non-blocking is because speed is import for
this
app. Waiting for even 1 sec might be too long. From what you are
saying,
it seems like I just have to live with this out-of-sync possibility.






As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.