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. ibook3
3. Minicom 1.7.0 + XMODEM + > 255 blocks = display problems
4. Proxy 2.0+RRAS+VPN->Linux???
5. Can't get SB 16 SCSI CDROM to work, not a block device :(
6. Anybody really knows Linux PPP ???
7. blocking short fragment in PF.
8. Glibc RealPlayer: working for anyone?
9. fsck complains short block for my new HD (Micropolis 3243)
10. EXT2: Defualt block-size & super-block pos.
11. Blocking connect() fails, non-blocking succeeds?
12. SCO tar error on block size (not block factor)
13. SVM resync -- all blocks or used blocks?