-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSocketUtil.hpp
More file actions
48 lines (37 loc) · 1.02 KB
/
Copy pathSocketUtil.hpp
File metadata and controls
48 lines (37 loc) · 1.02 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
#ifndef SOCKET_UTIL_HPP
#define SOCKET_UTIL_HPP
#include <stdio.h>
#include <iostream>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <cstring>
#include <unistd.h>
#include <pthread.h>
#include <vector>
using namespace std;
class AcceptedSocket {
public:
int acceptedSocketFD;
struct sockaddr_in address;
int error;
bool accepted;
AcceptedSocket() {
acceptedSocketFD = -1;
accepted = false;
}
AcceptedSocket(int acceptedSocketFD, struct sockaddr_in address) {
this->acceptedSocketFD = acceptedSocketFD;
this->address = address;
this->accepted = acceptedSocketFD > 0;
if(!this->accepted) {
this->error = acceptedSocketFD;
}
}
};
int createTCPIpv4Socket();
struct sockaddr_in* createIPv4Address(char* , int);
AcceptedSocket* acceptIncomingConnection(int);
void* listenAndDisplay(void *arg);
void startListeningAndDisplay(int );
#endif