-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathclient.h
77 lines (69 loc) · 1.23 KB
/
client.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<iostream>
#include<unistd.h>
#include<fcntl.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<assert.h>
#include<stdio.h>
#include<errno.h>
#include<signal.h>
#include<sys/wait.h>
#include<sys/stat.h>
#include<MD5.h>
using namespace std;
class userinfo
{
private:
string id;
string username;
public:
userinfo(char *m_id,char *name)
{
id(m_id);
username(name);
}
};
//REGISTERED=0,LOGIN,UPLOAD_F,UPLOAD_S,DOWNLOAD,ADDFRIEND,SHAREDTOFRIEND,SNOPSHOT
class start_process
{
public:
void RecvFriendAndFileList();
void deal_registered();
void RecvRetId();
void error_login();
void deal_login();
void start();
void file_start();
void deal_upload();
void deal_resumes_transmission(char *path);
void upload_file_to_server(char *path);
public:
void run()
{
start();
file_start();
}
start_process(int msockfd)
{
sockfd=msockfd;
pipe(pfd);
}
private:
userinfo m_user;
int sockfd;
int pfd[2];//splice用管道,记得初始化
};
char *mystrtok(char *tmp,char *s)
{
char *p;
char *temp=NULL;
p = strtok(tmp, s);
while (p != NULL)
{
temp = p;
p = strtok(NULL, s);
}
return temp;
}