具体功能: 客户端读取本地的文件,将内容发给服务器,服务器打印接收到的信息并返回当前服务器的时间,客户端接收到服务器发的消息,打印
客户端:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <netdb.h>
#include <fcntl.h>
#define MAX_THREAD 26
#define BUFFER_SIZE 1024
char *src_path = "/home/test";
struct MYPARAM
{
char *server_ip;
char *server_port;
};
//读取本地文件
void read_file(char buffer[], char* src)
{
char buffer1[1024];
int read_size;
int src_fd;
//打开本地文件
if((src_fd = open(src, O_RDONLY)) < 0)
{
perror("Open /home/test failed:");
exit(1);
}
//读取本地文件
if((read_size = read(src_fd, buffer, sizeof(b