Newbie Question: select function 
Author Message
 Newbie Question: select function

I just started working with sockets.

I wonder if the writefds argument for the select function is for
non-blocking write purpose because I don't really see the real use of
this argument for blocking write. It would be only useful if in the
select loop when an fd is ready for writing then some data can be
write to it without "for" looping on the write.

Am I correct ?

Thanks,
Ming



Sun, 27 Jun 2004 09:18:28 GMT  
 Newbie Question: select function

Quote:

> I just started working with sockets.

> I wonder if the writefds argument for the select function is for
> non-blocking write purpose because I don't really see the real use of
> this argument for blocking write. It would be only useful if in the
> select loop when an fd is ready for writing then some data can be
> write to it without "for" looping on the write.

> Am I correct ?

> Thanks,
> Ming

I think your question is off topic for this newsgroup - the people on
comp.unix.programmer are very nice and will help you out.

In my own amateur way, I could attempt to answer your question.  If the
fd is non blocking, you could just have a for loop, where you keep
attempting to write.  The problem with this is that going around this
for loop will use up a lot of CPU cycles.  On a multiuser system like
Unix, these CPU cycles could have been used by some other process.  Or
if there is no other process that needs to work, the computer could
execute a halt instruction, thus saving the CPU from heating up.  But if
you wait upon a select command (even if it has a timeout), you give back
that time to the kernel, and the kernel can give that time to a process
that has real work to do.

--
Stephen Montgomery-Smith

http://www.math.missouri.edu/~stephen



Sun, 27 Jun 2004 12:09:33 GMT  
 Newbie Question: select function

Quote:

> I just started working with sockets.

<snip>

sockets are off-topic in comp.lang.c
you should probably try a UNIX news grooup.

--
Nick Keighley



Sun, 27 Jun 2004 17:01:39 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. newbie question: returning structs from functions

2. Newbie Function question

3. Newbie question about function to get float

4. Newbie question: malloc() function

5. another newbie question: strncpy function

6. Newbie question: Pointer to an array and passing it into a function

7. Newbie question: Calling functions

8. Newbie question about fgets() Function

9. newbie question: exporting a string from a function using vc++4

10. newbie question: passing struct as argument to function ?

11. Newbie question: Returning LPSTR from a function

12. Newbie question about printing text and timer function

 

 
Powered by phpBB® Forum Software