socket文件传输,可以实现传输不同大小的文件(单个)

//structure_Function.h
#include <stdio.h>

struct data_Interaction
{
   
	int   count;
	char data_One[128];
	char data_Two[1024];
	char data_Three[1024];
};

//服务端
#include <stdio.h>
#include <sys/types.h>          /* See NOTES */
#include <sys/socket.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "structure_Function.h"


#define  LS  1
#define  PWD 2
#define  GET 3
#define  CD  4 


int Strcmp(char *s)
{
   
	if(strcmp(s,"ls")==0){
   
		return LS;
	}

	if(strcmp(s,"pwd")==0){
   
		return PWD;
	}
	if(strstr(s,"get")!=NULL){
   
		return GET;
	}

	if(strstr(s,"cd")!=NULL){
   
		return CD;
	}
}
char *get_chdir(char *q)
{
   
	char *t=NULL;
	t=strtok(q," ");
	t=strtok(NULL," ");
	return t;
}
void  get_Des(struct data_Interaction msg,int c_fd)
{
   
	int fd;
	int size;
	int count=0;
	int remainder=0;
	int w_write;
	int n_read;
	int ret;
	char buf[1024]={
   0};	
	char *from_GetChdir=NULL;
	FILE *r=NULL;
	ret = Strcmp(msg.data_One);
	printf("msg.data_One:%s\n",msg.data_One);
	memset(msg.data_Two,0,sizeof(msg.data_Two));
	switch(ret){
   
		case CD :
		from_GetChdir=get_chdir(msg.data_One);
		ch
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值