-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTCP_interface.cpp
More file actions
68 lines (56 loc) · 1.57 KB
/
TCP_interface.cpp
File metadata and controls
68 lines (56 loc) · 1.57 KB
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
#include "common_include.h"
#include "common_def.h"
#include "TCP_client.h"
#include "TCP_manager.h"
#include "TCP_interface.h"
#include "TCP_tool.h"
#include "session_manager.h"
#include "file_index.h"
#include "disk_task.h"
#include "disk_info.h"
#include "disk_pending_pool.h"
#include "disk_fsm.h"
#include "disk_thread.h"
#include "disk_thread_pool.h"
#include "disk_manager.h"
using namespace std;
namespace ftp_server
{
extern session_manager *g_session_man;
extern disk_manager *g_disk_man;
extern _ftpserver_config g_config;
extern TCP_interface *g_tcp;
extern TCP_tool *g_tcp_tool;
/** 运行TCP接口线程 */
void *run_TCP(void *par)
{
cout<<"TCP Interface is running."<<endl;
TCP_interface *p_TCP_i = (TCP_interface *)par;
TCP_manager *p_TCP_m = p_TCP_i -> get_TCP_manager(); //获取TCP管理器
// p_TCP_m -> listen_socket =
p_TCP_m -> init_listen_socket(); //p_TCP_m -> listen_socket);
cout<<"Init listen socket success."<<endl;
p_TCP_i -> init_TCP_event(p_TCP_i);
cout<<"Init TCP event success."<<endl;
return NULL;
}
/** 主程序通过该函数启动TCP_interface */
bool TCP_interface::start_proc()
{
pthread_t TCP_id;
int ret;
/*启动支持TCP协议接口的线程*/
ret = pthread_create(&TCP_id, NULL, run_TCP, (void *)this);
if(ret != 0)
{
cout<<"Create TCP thread error: "<<strerror(ret)<<endl;
return false;
}
else
{
cout<<"Create TCP interfae success."<<endl;
return true;
}
pthread_detach(TCP_id);
}
}