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
| #pragma once
| #include<WinSock2.h>
| #include <WS2tcpip.h>
| #pragma comment(lib,"ws2_32.lib")
| #include <stdio.h>
| #include <stdlib.h>
| #include <windows.h>
| #include <list>
| #include <iostream>
| #include "framework.h"
| #include <atlstr.h>
| using namespace std;
| class SocketManager
| {
|
|
| private:
| list<SOCKET> sockClients;
| const int PORT = 9001;
| const char* ADDR = "127.0.0.1";
| sockaddr_in clientaddr;
| SOCKET getClient(int p);
| //Ìí¼Ó¿Í»§¶Ë
| void addClient(int p);
|
|
|
| public:
| SocketManager();
| ~SocketManager();
|
| void init();
|
| int getClientsNum();
|
| //Á¬½ÓËùÓÐ
| int Connect();
| int Connect(int p);
|
| //¶Ï¿ªËùÓÐ
| void disConnect();
| int disConnect(int p);
|
| BOOL sendMsg(int,char *);
|
|
| };
|
|