Changed TCPServer to use IPAddress.
This commit is contained in:
1 parent
8d6f414086
commit
41ff757f09
183 files changed
+2139
-878
No files matched your search
+20
-1
@@ -4,8 +4,27 @@ namespace core {
|
||||
|
||||
IPAddress::IPAddress() {
|
||||
addressLength = sizeof(struct sockaddr_in);
|
||||
pointer = (sockaddr *)&address;
|
||||
}
|
||||
|
||||
|
||||
IPAddress::IPAddress(std::string address) {
|
||||
std::string url = address.substr(0, address.find(":"));
|
||||
std::string s_port = address.substr(address.find(":") + 1);
|
||||
std::stringstream convert(s_port);
|
||||
short int port = 0;
|
||||
convert >> port;
|
||||
IPAddress(url, port);
|
||||
}
|
||||
|
||||
IPAddress::IPAddress(std::string address, short int port) {
|
||||
struct sockaddr_in addr;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(port);
|
||||
struct hostent *hp = gethostbyname(address.c_str());
|
||||
memcpy((void *)&addr.sin_addr, hp->h_addr_list[0], hp->h_length);
|
||||
}
|
||||
|
||||
IPAddress::~IPAddress() {
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user