-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTcp.h
60 lines (55 loc) · 2.59 KB
/
Tcp.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
/************************************************************
* File description: TCP header file. the class inherit from *
* socket. methods of tcp socket type *
************************************************************/
#ifndef TCP_H_
#define TCP_H_
#include <vector>
#include "Socket.h"
class Tcp: public Socket {
private:
int descriptorCommunicateClient[500];
vector<unsigned int *> freeAddr;
vector<struct sockaddr_in *> freeSock;
public:
/***********************************************************************
* function name: Tcp *
* The Input: Boolean, true - if server, false if client and port number*
* The output: none *
* The Function operation: creating new Tcp *
***********************************************************************/
Tcp(bool isServers, int port_num, string ip);
/***********************************************************************
* function name: ~Tcp *
* The Input: none *
* The output: none *
* The Function operation: default destructor *
***********************************************************************/
virtual ~Tcp();
/***********************************************************************
* function name: initialize *
* The Input: none *
* The output: int number representing the return status *
* The Function operation: initialize the Socket object and getting a *
* socket descriptor. *
***********************************************************************/
int initialize();
/***********************************************************************
* function name: sendData *
* The Input: string representing the data to send *
* The output: int number representing the return status *
* The Function operation: sending the input data to the socket *
* who connect to this socket. *
***********************************************************************/
int sendData(string data, int id);
/***********************************************************************
* function name: recive ` *
* The Input: none *
* The output: int number representing the return status *
* The Function operation: getting data from the other socket and print *
* the data *
***********************************************************************/
int reciveData(char* buffer, int size, int id);
int acceptSock();
};
#endif /* TCP_H_ */