Re: select() timeout question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Randi Botse wrote:
Hi All,

Im now learning the Linux's select() system call,

#include <sys/select.h>

int select(int fd, fd_set *rset, fd_set *wset, fd_set *excepfs, struct
timeval *timeout);

I want to receive notification when the given file descriptor is ready
to read, i use TCP socket connection to demonstrate this, one for the
sender and other for the receiver, with normal condition, when the
sender send data via write(), the select() returns and tell the
receiver there are data to read.

My question is: what happen when the receiver's select() is reaching
it's timeout while the sender send data? should the notification and
it's data lost (discarded)?
NO! if timeout ,the data will stay in kernel, and select will notice you when the select called again,

In fact , we always put select in while loop and set the timeout!
Based on my above experiment, select() never fail to notify although
it's in timeout state, and i awalys can read the data, i'm curious
with this, but i'm not sure if this always right.

Thanks before.

                                            Randi,
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
---------------------------------
Zhenwen Xu - Open and Free
Home Page:	http://zhwen.org

--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

Add to Google Powered by Linux