-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrSocket.cc
More file actions
27 lines (20 loc) · 761 Bytes
/
TrSocket.cc
File metadata and controls
27 lines (20 loc) · 761 Bytes
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
#include "TrSocket.hh"
//TrSocket::TrSocket() {}
//TrSocket::~TrSocket() {}
void TrSocket::setup(const char* serviceName, const char* host) {
service = serviceName;
hostname = host;
memset(&hostInformation, 0, sizeof(hostInformation));
hostInformation.ai_family = AF_UNSPEC;
hostInformation.ai_socktype = SOCK_STREAM;
hostInformation.ai_flags = AI_PASSIVE;
int status = getaddrinfo(hostname, service, &hostInformation, &hostInformationList);
std::cout << status << std::endl;
}
void TrSocket::create() {
socketIdentifier = socket(hostInformationList->ai_family, hostInformationList->ai_socktype,hostInformationList->ai_protocol);
if (socketIdentifier == -1) std::cout << "socket error " ;
}
void TrSocket::end() {
close(socketIdentifier);
}