Yes indeed, your issue is not that the socket is adding new lines (sockets never process or change data) Instead your call to fgets is simply catching the newline you type. You can remove it with this handy one liner:
buffer[strlen(buffer) - 1] = '\0';
which must be between the fgets and the write.
To be a little safer it would be better to use
if('\n' == buffer[strlen(buffer) - 1])
buffer[strlen(buffer) - 1] = '\0';