-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.cc
40 lines (32 loc) · 813 Bytes
/
client.cc
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
#include "client.hh"
#include <iostream>
HBClient::HBClient() { }
HBClient::HBClient(string hip, int hport) {
sock = Socket(AF_INET, hip, hport);
hostip = hip;
HBClient();
}
/* Accessor methods */
string HBClient::cname() const {
return sock.getsrcname();
}
string HBClient::client() const {
return sock.getsrcip();
}
string HBClient::host() const {
return sock.getsinip();
}
/* Establish connection to destination */
/* move to its own netops library
int HBClient::connectsin() {
return connect(sock.getfd(),
sock.getsin(),
sizeof(sock.getsin()));
}*/
int main() {
HBClient c("127.0.0.1", 5070);
cout << "client name: " << c.cname() << endl;
cout << "client IP: " << c.client() << endl;
cout << "host IP: " << c.host() << endl;
return 0;
}