Re: When is it OK to change O_NONBLOCK mode of a socket?
- From: Barry Margolin <barmar@xxxxxxxxxxxx>
- Date: Sun, 11 May 2008 23:57:53 -0400
In article
<2419d918-a467-4c06-ac4a-fcbfd1adf358@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"jason.cipriani@xxxxxxxxx" <jason.cipriani@xxxxxxxxx> wrote:
First of all, what I want to do:
1. Create socket (will be either SOCK_STREAM/SOCK_DGRAM + PF_INET).
2. Set as nonblocking.
3. Connect with timeout (connect + select).
4. Set as blocking.
5. Other I/O stuff.
In my application, a blocking socket is more convenient, but I would
like to set it to non-blocking mode for connect() so I have control
over the timeout. Is this always OK?
Yes.
Also, in general, are there any rules about when it's OK to change the
blocking/non-blocking mode of a socket? Can I just do it arbitrarily?
Yes. It just affects future calls to operations that can block.
--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
.
- Follow-Ups:
- Re: When is it OK to change O_NONBLOCK mode of a socket?
- From: Ian Collins
- Re: When is it OK to change O_NONBLOCK mode of a socket?
- From: jason.cipriani@xxxxxxxxx
- Re: When is it OK to change O_NONBLOCK mode of a socket?
- References:
- When is it OK to change O_NONBLOCK mode of a socket?
- From: jason.cipriani@xxxxxxxxx
- When is it OK to change O_NONBLOCK mode of a socket?
- Prev by Date: When is it OK to change O_NONBLOCK mode of a socket?
- Next by Date: Re: When is it OK to change O_NONBLOCK mode of a socket?
- Previous by thread: When is it OK to change O_NONBLOCK mode of a socket?
- Next by thread: Re: When is it OK to change O_NONBLOCK mode of a socket?
- Index(es):
Relevant Pages
|