Here is my simplified version of the tcp client, server chat application client.c #include "stdio.h" #include "stdlib.h" #include "sys/types.h" #include "sys/socket.h" #include "arpa/inet.h" int main() { int sockfd,n; char buff[256]; struct sockaddr_in servaddr; //create socket sockfd = socket(AF_INET,SOCK_STREAM,0); //fill serv struct servaddr.sin_family = AF_INET; servaddr.sin_port = htons(40402); servaddr.sin_addr.s_addr = inet_addr("127.0.0.1");