fixed a lot of jank. created a utils file and removed unused files

This commit is contained in:
Diego Waxemberg
2014-10-20 19:20:50 -04:00
parent 283a386b9c
commit 37428c8c77
21 changed files with 209 additions and 516 deletions
-33
View File
@@ -8,10 +8,6 @@
#import "Computer.h"
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
@implementation Computer
- (id) initWithHost:(NSNetService *)host {
@@ -23,33 +19,4 @@
return self;
}
- (int) resolveHost
{
struct hostent *hostent;
if (inet_addr([self.hostName UTF8String]) != INADDR_NONE)
{
// Already an IP address
int addr = inet_addr([self.hostName UTF8String]);
NSLog(@"host address: %d", addr);
return addr;
}
else
{
hostent = gethostbyname([self.hostName UTF8String]);
if (hostent != NULL)
{
char* ipstr = inet_ntoa(*(struct in_addr*)hostent->h_addr_list[0]);
NSLog(@"Resolved %@ -> %s", self.hostName, ipstr);
int addr = inet_addr(ipstr);
NSLog(@"host address: %d", addr);
return addr;
}
else
{
NSLog(@"Failed to resolve host: %d", h_errno);
return -1;
}
}
}
@end