🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #69676

Re: POST -> no response, but message is posted.

#69676
From: Russ Allbery
Date: Mon, 09 Aug 2004 05:33
47 lines
3856 bytes
Curt Welch <curt@kcwc.com> writes:

> Many programming langages however offer special nonblocking versions of
> fuctions like disk IO, and network IO.  So, for disk IO, the program can
> make a request to read a block from disk, but not block, and continue
> processing - but the programer of course has to deal with the fact that
> the data requested will show up at some time in the future.

Strictly speaking, that's asynchronous I/O, which is yet another thing.
By default, I/O is blocking and synchronous.  Non-blocking I/O is still
synchronous by default; when you read from your file or network
connection, you will either get the data back immediately or you'll get an
indication that there was no data.  The only difference between blocking
and non-blocking is that in the non-blocking case, you'll get an error
when there isn't any data instead of just waiting until there is some.
(As Curt does go on to explain.)

Asynchronous I/O is yet another mode of operation, where you request a
read, that read returns success, and at some point later on the data
magically shows up in the relevant memory buffer.  That involves a
different type of programming that's closer to what you have to do with
threads, where multiple things are happening in your program at the same
time, although it's not quite as complicated.  You have to be careful
about things like not using the buffer until the data magically shows up,
though, that you don't have to worry about with non-blocking I/O.

I mention this just because there was at least one transit news server
written to use asynchronous I/O using the aio_read() family of functions
available on various platforms.

> If the routines you are using do not support a blocking read, but you do
> have the ability to do a select(), then you should do that.  Use select
> to wait for the data, and then read the data once the select() says it's
> there.  The select is a blocking call which will cause the program to
> puase until the data shows up, but allow it to continue when it shows
> up, so there will be no extra delays in your code.

Nearly all programs using non-blocking I/O should be using select() or
poll().  It's generally a sign that something isn't right if a program
uses non-blocking I/O but never calls either select() or poll(), or some
framework function that ends up calling them undert he hood.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Technical Details
Message-ID: <87hdrcg9j4.fsf@windlord.stanford.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20140818.mbox.gz!number1.nntp.dca.giganews.com!internal1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!feed2.news.rcn.net!feed1.news.rcn.net!rcn!logbridge.uoregon.edu!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mail
References: <20040808125855.840$hk@newsreader.com> <41167396$0$28854$9b4e6d93@newsread4.arcor-online.net> <20040808224221.335$Rb@newsreader.com>

Show Full Headers
Complete Article Headers
Message-ID: <87hdrcg9j4.fsf@windlord.stanford.edu>
Subject: Re: POST -> no response, but message is posted.
Date: Sun, 08 Aug 2004 22:33:51 -0700
From: Russ Allbery <rra@stanford.edu>
References: <20040808125855.840$hk@newsreader.com> <41167396$0$28854$9b4e6d93@newsread4.arcor-online.net> <20040808224221.335$Rb@newsreader.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20140818.mbox.gz!number1.nntp.dca.giganews.com!internal1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!feed2.news.rcn.net!feed1.news.rcn.net!rcn!logbridge.uoregon.edu!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mail
Newsgroups: news.software.nntp
Organization: The Eyrie
Lines: 47
NNTP-Posting-Host: windlord.stanford.edu
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.Stanford.EDU 1092029631 21782 171.64.19.147 (9 Aug 2004 05:33:51
 GMT)
X-Complaints-To: news@news.stanford.edu
User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through
 Obscurity, linux)
Cancel-Lock: sha1:KyL5zx8AqTHerOsPEzrVvYZLlgc=