incomplete socket writes (when write blocks)

incomplete socket writes (when write blocks)

Post by Neil Zanell » Thu, 20 Feb 2003 16:57:38



Hello,

I was wondering whether it is possible for a write on
a connected socket descriptor to return without completing,
writing only part of the data, with no error being returned.
Is this possible even when write blocks (as it usually does).

Thanks,

Neil

 
 
 

incomplete socket writes (when write blocks)

Post by Barry Margoli » Fri, 21 Feb 2003 01:12:51




Quote:>I was wondering whether it is possible for a write on
>a connected socket descriptor to return without completing,
>writing only part of the data, with no error being returned.
>Is this possible even when write blocks (as it usually does).

I think it can happen if it's interrupted by a signal.  If it returned -1
and set errno to EINTR in this case you wouldn't know how much it had
partially written, so instead it returns "successfully" and returns the
number of bytes that were written.  So the EINTR error is only reported if
the signal occurred before any data was transferred.

--

Genuity Managed Services, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

1. Sockets: write() writes OK, yet read() reads garbage...?

Strange thing happens. There is a TCP socket established between A and B. Some
information flows OK between the two. However, one particular sequence of
communication does not. A writes a command to B, and immediately goes into
read() for a responce. B does something with the message and writes back to A a
struct, with some fields set to important values. When A reads it (as the same
struct - both use the same header file), however, it contains garbage. All the
fiels are set to 0 (zero). And it reads the correct size of the struct:

  n = read( sock, &preamble, sizeof(preamble) );
  if( n < 0 || n > sizeof(preamble) )
   error...

What/where can the problem be? Does A (or maybe B) have to flush the socket
after it wrote a command, to make sure it does not read its own packet back?

Thanks.
--
Simon   B-)>

2. Video Cards

3. Problem on tcp socket:two consecutive writes takes much much longer time than single write, why?

4. gcc Binaries

5. TCP Socket Non-Blocking write ?

6. /etc/profile on start

7. Q: write() to TCP socket blocking

8. ICT what does it really mean; GMT can it be done?

9. non-blocking writes to sockets

10. Problem with non-blocking writing using sockets

11. write()ing to a blocking socket

12. Getting value of file pointer for socket, OR am I blocked on a write?

13. blocking write() & other socket questions