In your server code the read() should use the socket descriptor returned from the accept() not from the call to socket(). So try reading using newSocket rather than welcomeSocket.
n = read(newSocket,buffer,255);
1
solved Server Client program in C using sockets and tcp