Line 149 and 150 of server_test.c should read len = read(client, buf, sizeof(buf) - 1); buf[len] = '\0'; After all, we're using "buf" as a "C" string buffer and we need to reserve one byte for the null. Otherwise the last character is cut off by line 150 setting it to null.