server side child func: recv client data,then shutdown the socket
server side child func:
char line[1024];
bzero(line,sizeof(line));
int ret = recv(fd,line,sizeof(line),0);
if(ret > 0){
cout << line << endl;
}else if(ret < 0){
cout << "recv error" << endl;
}else if(ret == 0){
cout << "client close" << endl;
break;
}
shutdown(fd,SHUT_WR);
client side main func
char line[] = "ds2d2d2d2d21dwq";
send(sockfd,line,sizeof(line),0); //send to server
//server side the child func has exit
sleep(20);
cout << "write to server" << endl;
//write to server again
ret = send(sockfd,line,sizeof(line),0);
perror("write...."); //write success
//according to unp book ,the server has send the RST msg to client
bzero(line,sizeof(line));
sleep(5);
//recv should return error and the error code should ECONNRESET
//but not appear , the recv success return 0(EOF)
//then execute recv success return 0(EOF)
ret = recv(sockfd,line,sizeof(line),0);
cout << ret <<line << endl;
perror("recv....");
ret = recv(sockfd,line,sizeof(line),0);
perror("recv....");
I don't know Is it right? Kernel improvements. I found the recv system don't have ECONNRESET error code