Hello,
i would like to know, what is the Difference between Blocking and
non-Blocking I/O ??
Thank you??
Natallia Shapel.
i would like to know, what is the Difference between Blocking and
non-Blocking I/O ??
Thank you??
Natallia Shapel.
> i would like to know, what is the Difference between Blocking and
> non-Blocking I/O ??
-
Barrett
1. Non blocking socket blocks; says 'read would block' ?
Hi all,
I have three sockets in server which I am reading in a continuous loop,
so don't want to wait on any one. I have designated them as 'non blocking'
but when run the server exits on the very first read() and says 'would
block'. (Is it the same as 'EWOULDBLOCK' mentioned in R. Steven's book ?)
I don't want that I should get any error msg and exit, in fact the
whole purpose of nonblocking is that if something is available, read it
else proceed in the loop and come back to read next time.
The client (sender) is sending msgs on all three sockets. The sockets
are conn_oriented. I am using SunOS 4.1. The small code part is below:
int emer_s, env_s, sens_s; /* socket fds */
//----------- making sockets nonblocking ******
if ((res=fcntl(emer_s,F_SETFL,FNDELAY)) < 0)
{
perror("fcntl res = -1");
exit(1);
}
if ((res=fcntl(env_s,F_SETFL,FNDELAY)) < 0)
{
perror("fcntl res = -1");
exit(1);
}
if ((res=fcntl(sens_s,F_SETFL,FNDELAY)) < 0)
{
perror("fcntl res = -1");
exit(1);
}
for(; ;)
{
if ((cc=read(emer_s,(char*)&gen_struct,size)) < size)
{
perror("read error");
exit(1);
}
......... do something
if ((cc=read(env_s,(char*)&gen_struct,size)) < size)
{
perror("read error");
exit(1);
}
......... do something
if ((cc=read(sens_s,(char*)&gen_struct,size)) < size)
{
perror("read error");
exit(1);
}
......... do something
}
Any help is appreciated.
hashmi
--
-----
Atiqullah Hashmi
UTA (Univ. of Texas at Arlington)
2. Trackpad & PS/2 mouse Jumping
3. Non-Block read & Block read
4. best way to re-dial a ppp connection
5. Blocking connect() fails, non-blocking succeeds?
7. Blocking and Non-Blocking socket
8. init level 3 and 4 hang on bootup; init 1 works
9. [2.2] pipe_write can block even with non-blocking fd
10. how to get blocking i/o after non-blocking???
11. [2.5] Non-blocking write can block
12. Non-blocking socket reads block! (Bug?)
13. Problem with blocking opens preventing non-blocking opens in AIX 5.2