+ if (self = [super init])
+ {
+ state = ITInetSocketDisconnected;
+ sockfd = -1;
+ delegate = [d retain];
+ port = 0;
+ writePipe = [[ITByteStream alloc] init];
+ readPipe = [[ITByteStream alloc] init];
+ ai = nil;
+ }
+ return self;
+}
+
+-(void) connectToHost:(NSString*)host onPort:(short)thePort
+{
+ if (state == ITInetSocketDisconnected)
+ {
+ struct addrinfo hints;
+ int err;
+ const char *portNam = [[[NSNumber numberWithShort:thePort] stringValue] cString], *hostCStr = [host cString];
+
+ hints.ai_flags = 0;
+ hints.ai_family = PF_INET6;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = IPPROTO_TCP;
+ hints.ai_canonname = NULL;
+ hints.ai_addr = NULL;
+ hints.ai_next = NULL;
+
+ err = getaddrinfo(hostCStr,portNam,&hints,&ai);
+ if (err == EAI_NODATA) //it's a dotted-decimal IPv4 string, so we use v6compat stuff now
+ {
+ err = getaddrinfo([[NSString stringWithFormat:@"ffff::%s",hostCStr] cString],portNam,&hints,&ai);
+ }
+ NSLog([self dumpv6Addrinfo:ai]);
+ }
+}
+
+-(ITInetSocketState)state
+{
+ return state;