How does 'send' block ?

How does 'send' block ?

Post by Sergio Rodriguez Lombarde » Tue, 11 Jun 1996 04:00:00



Hello !

In a post to the threads group, i asked why in some cases the send call
doesn't block until all the data is sent. I have been answered that this is
the right behaviour of this system call.

However, I think it is a bit strange that there is not a way to do a
'syncrounous send'. I have been told that is has something to do with
the buffer length, but usually I have sent data of more than 10 megabytes
in a single 'send' without detecting any problem.

If there is no way to do a syncronous 'send'... why is the related man page
describing the O_DELAY and O_NONBLOCK flags to make asyncronous a socket
descriptor ?

Well, if someone read this and has clear ideas about the question, every
help will be useful.

Bye !

 
 
 

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. dial on demand with modem

3. drivers/block/block.o: In function `rd_blkdev_pagecache_IO' and `rd_make_request': undefined reference to `bio_size'

4. Top ten Linux sites

5. Why is mail for 'news' not sent to 'root'?

6. stty erase

7. starting off a dos-smtp-''project''

8. Problems w/ 3Com 3c900 XL (PCI)

9. Is e2label 'dangerous' when done on a 'live' file system?

10. NEC-260; Can't mount; Get 'not a block device error'

11. NEC-260R; Can't mount; Get 'not a block device' error

12. send-mail: can't load library 'libgdbm.so.2'

13. NEC-260R; Can't mount - 'not a block device' error