FTP 上传下载,多进程,多线程上传(1)
来源:互联网 发布:python 爬知乎 编辑:程序博客网 时间:2024/06/08 08:54
//ftp_client.h
#ifndef _FTP_CLIENT
#define _FTP_CLIENT
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <pthread.h>
using namespace std;
#define UNIX_SPACE ' '
#define UNIX_TABLESPACE '/t'
#define UNIX_NEWLINE '/n'
#define LEFT_SIGN '['
#define RIGHT_SIGN ']'
#define DATA_TRANS_SUCC "226"
#define WAIT_TIMES 50
#define DEF_BUFFER_SIZE 4096
#define PROC_COUNT 5
static char CONFIG_FILE_PATH[]="./configfile.txt";
static char LIST_FILE_PATH[]="./listfile.txt";
enum FTP_CMD {USER, PASS, PWD, TYPE, PORT, LIST, CWD, SIZE, RETR, REST, PRETR, TRETR, STOR, QUIT};
typedef int(*PFV)(char*, char*);
struct Login_Infor
{
char user[20];
char password[20];
char serverIp[20];
int serverPort;
char type;
char serverPath[50];
char localIp[20];
int localPort;
char localPath[50];
};
struct Load_Task
{
pid_t pid;
int state;
int offset;
int size;
char desPath[30];
char srcPath[30];
};
struct THREAD_LOAD_TASK
{
Load_Task* pthread_load;
int iNode ;
char file_name[30];
};
class BASE_OBJECT
{
public:
BASE_OBJECT();
virtual ~BASE_OBJECT();
virtual bool excute(){ return true; };
virtual bool getValue(const char* src, char* des1, char* des2);
virtual bool analyse( const char* path);
virtual bool getValueByFixChar(char* src, char des[][10], char sign);
virtual bool copyFile(char * srcFile, char* desFile, char* openSign="a+");
static bool getValueByFixChar2(char* src, char des[][30], char sign);
protected:
static Login_Infor* pLoginInfor;
};
class FTP_CLIENT : public BASE_OBJECT
{
public:
FTP_CLIENT();
virtual ~FTP_CLIENT();
virtual bool excute() { return true; };
bool ftpInit();
bool ftpCmd(int socketId, FTP_CMD strCmd, int paraInt=0, char* paraStr=NULL, PFV pf=NULL);
bool ftpExcute(int socketId, char* sendCmd, char* returnCode, int waitTimes=WAIT_TIMES);
bool ftpListen();
bool ftpDownLoad(const char* pSavePath=NULL);
bool ftpProcDownLoad(const Load_Task* pInfor);
bool ftpUpLoad(const char* pUpPath);
bool ftpSendSucc(int socketId, char* sendCmd);
bool ftpRecvSucc(int socketId, char* returnCode=NULL, int waitTimes=WAIT_TIMES, bool IsNeedRecv=true);
static void* ftpThreadFunc(void* p);
static int getOneFileSize(char* path, char* para);
int controlSock;
int listenSock;
int transferSock;
int tSize;
char cmdBuffer[128];
struct THREAD_LOAD_TASK pthread_loadtask;
private:
struct sockaddr_in serverAddr;
struct sockaddr_in clientAddr;
struct Load_Task *pLoadTaskInfor;
};
#endif
- FTP 上传下载,多进程,多线程上传(1)
- FTP 上传下载,多进程,多线程上传(2)
- VC FTP多线程上传下载
- java实现FTP多线程断点续传,上传下载!
- java实现FTP多线程断点续传,上传下载
- java实现FTP多线程断点续传,上传下载!
- java实现FTP多线程断点续传,上传下载!
- java实现FTP多线程断点续传,上传下载!
- java实现FTP多线程断点续传,上传下载!
- java实现FTP多线程断点续传,上传下载!
- java实现FTP多线程断点续传,上传下载!
- 利用ftp多线程上传文件
- ftp上传下载
- FTP上传下载
- FTP上传下载
- FTP上传下载
- 上传下载ftp
- ftp上传下载
- 7-11的布局兵法(转自《实战电子商务》)
- 虚拟内存——Windows核心编程学习手札之十四
- C++ template - 模板的模板参数
- 常用正则表达式
- Struts2.1.x+Spring2.5.x+Hibernate3.2.x实例教程(2)V0.1
- FTP 上传下载,多进程,多线程上传(1)
- 不同的标签初始背景与滑过背景巧妙实现
- 完整正确的wav文件格式分析详解
- Java牛角尖【010】: 当对象a.equals(b)时,a.hashCode == b.hashCode吗?
- c# 根据当前时间获取,本周,本月,本季度,月初,月末,各个时间段
- 使用JavaScript在表中指定位置插入一行
- 手工建的账号能访问SVN,不能用LDAP账号登录SVN的故障
- UIComponent之life cycle
- 关于SMOD和CMOD