概述
//client
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<netinet/in.h>
#include<string.h>
#include<dirent.h>
#include<fcntl.h>
#include<errno.h>
#define errlog(errmsg) do{
perror(errmsg);
exit(-1);
}while(0)
#define N 32
int start_up(struct sockaddr_in serveraddr);
void do_find(struct sockaddr_in serveraddr);
void do_get(struct sockaddr_in serveraddr,char *filename);
void do_put(struct sockaddr_in serveraddr,char *filename);
int main(int argc, const char *argv[])
{
char buf[N] = {};
int ret;
struct sockaddr_in serveraddr;
serveraddr.sin_family = AF_INET;
serveraddr.sin_port = htons(atoi(argv[2]));
serveraddr.sin_addr.s_addr = inet_addr(argv[1]);
while(1)
{
puts("****************************");
puts("* find filename * ");
puts("* get filename * ");
puts("* put filename * ");
puts("****************************");
printf("input:");
fgets(buf,N,stdin);
buf[strlen(buf) - 1] = '