From one thread I got the following code:
int next_stuff(char **code){ ... len=read(file_desc,buffer+end_len,packet_size-end_len); if(len<=0) { if(len==-1 && errno==EAGAIN) return(0); else return(-1); } ... } while (next_stuff(&buff) == 0) { ... }
On the other thread I’d like to finish that socket and exit this operation, but only doing a
close(file_desc);
does not cause read to return nonblocked. Am I missing something?
EDIT:
shutdown does not work as well. And I am trying that on Linux 2.6.23
shutdown(fd, SHUT_RD);
$ man -s 2 shutdown
NAME shutdown — shut down part of a full-duplex connection
SYNOPSIS
DESCRIPTION
RETURN VALUES