The steps to test the problem
- Open TCP Server
- Open TCP Client
- TCP Client sends data to Server.
- Close TCP Server and the client also crash without any notification
Second wonderful test:
- Comment the following statement in Client.c (at line 168) and compile it
Writen( sockfd, data.send_buf, strlen( data.send_buf ), __FILE__, __LINE__ );
- Run TCP Server
- Run TCP Client (since no writen(), so response from server, it is OK)
- Close TCP Server
- A lot of rubbish from TCP Server.........
I also posted the source code here.
Compile TCP Server
gcc -Wall -lmcheck -g -Werror -lpthread -o server server.c
Compile TCP Client
gcc -Wall -lmcheck -g -Werror -lpthread -o client Client.c lib/*.c