概述
客户端、长连接和心跳包参考博客:http://blog.csdn.net/zh724738989/article/details/42007099
客户端
服务器端C代码(0.01版):
/**************服务器端程序***************/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <time.h>
int sockfd;
char *hbResponse = "ok";
void do_service(fd)
{
char buf[100];
char hb[] = "hb";
int i;
int len = recv(fd,buf,100,0);/*读取信息*/
if(len < 0){
printf("recv error!n");
exit(1);
}else if (len == 0){
printf("the client quit!n");
}else {
buf[len] = '