interrupting socket read/write calls

interrupting socket read/write calls

Post by Ronaldo Carp » Fri, 29 Jun 2001 10:15:52



How can one force an ongoing socket read()/write() call to
return immediately?  The methods I'm aware of are sending a
signal to the thread doing the call, and closing the
descriptor in use from another thread.  Also, would these
methods work if the network cable were pulled out, the
other host lost power, etc.  Thanks in advance.

Ronnie N. Carpio

 
 
 

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. Stock RH6.2 recompile buggy...Normal?

3. Question on writing c program implement cp function using UNIX system calls - read, write, etc.

4. Problem with pppd & USR Sportster 33.6

5. Need help writing C program using UNIX system calls (read, write, etc) that copies files

6. The Well-Tempered Unix Application

7. write (socket, buf, 0) and read (socket, buf, 0)

8. help on incompatible libs

9. Interrupted system call and sockets --> Help

10. read: interrupted system call ?

11. Interrupted read(2) call

12. HELP: How to write a socket call ...

13. Read & Write MSR system calls