linux socket通信做的聊天程序有关问题

linux socket通信做的聊天程序问题
这是我用linux下socket编程做的服务器程序:
#include <pthread.h>
#include <stdio.h>
#include <netinet/in.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <netdb.h>
#include <stdlib.h>
#include <sys/ipc.h>
#include <sys/types.h>
#include <sys/msg.h> 
#include <string.h>   

#define BACKLOG 1
void* fwq_fun()
{
int socket_ret;
int bind_ret;
int listen_ret;
int accept_ret;
int cho = 1;

struct sockaddr_in pin;
struct sockaddr_in accept_info;
unsigned int port = 6666;

memset(&pin,0,sizeof(pin));
pin.sin_family = AF_INET;
pin.sin_port = htons(port);
pin.sin_addr.s_addr = htonl(INADDR_ANY);

socket_ret = socket(AF_INET, SOCK_STREAM, 0);
if (socket_ret < 0)
{
printf("socket:fail\n");
return NULL ;
}
setsockopt(socket_ret, SOL_SOCKET, SO_REUSEADDR, &cho, sizeof(cho));
bind_ret = bind(socket_ret, (struct sockaddr*)&pin, sizeof(pin));
if (bind_ret < 0)
{
printf("bind_ret:fail  %d\n", errno);
return NULL ;
}

listen_ret = listen(socket_ret, BACKLOG);
if (listen_ret < 0)
{
printf("listen_ret:fail %d\n", errno);
return NULL ;
}

while (1)
{
char buf[30] = {0};
accept_ret = accept(socket_ret, (struct sockaddr *)&accept_info, (socklen_t *)sizeof(accept_info));
if (accept_ret < 0)
{
printf("accept_ret:fail %d\n", errno);
return NULL ;
}

fgets(buf, sizeof(buf), stdin);

send(accept_ret, buf, sizeof(buf), 0);

}

close(socket_ret);
close(accept_ret);

return NULL;

}

int main()
{
pthread_t fwq_thread;
int ret = pthread_create(&fwq_thread, NULL, fwq_fun, NULL);
if (ret != 0)
{
perror("bao_fun:fail\n");
return -1;
}

pthread_join(fwq_thread, NULL);
return  0;
}






这是客户端程序: