Skip to content

Commit

Permalink
Update Tcping.m
Browse files Browse the repository at this point in the history
  • Loading branch information
paradiseduo authored Sep 18, 2023
1 parent 1b84c48 commit 5963504
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tcping/Tcping.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ - (instancetype)initWith:(dispatch_group_t)group queue:(dispatch_queue_t)queue {
return self;
}

- (void)connectSocket:(NSString *)domain port:(UInt16)port {
- (void)connectSocket:(NSString *)domain port:(UInt16)port timeout:(NSTimeInterval)timeout {
_domain = domain;
_port = port;
_socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:_queue];
if (!_socket.isConnected) {
dispatch_group_enter(_group);
_startTime = [NSDate date];
NSError * error = nil;
[_socket connectToHost:domain onPort:port withTimeout:1.0 error:&error];
[_socket connectToHost:domain onPort:port withTimeout:timeout error:&error];
if (error) {
dispatch_group_leave(_group);
}
Expand All @@ -53,6 +53,7 @@ - (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err {
if (err) {
[ConsoleIO writeMessage:[err localizedDescription] to:OutputTypeError];
dispatch_group_leave(_group);
[sock disconnect];
}
}
@end

0 comments on commit 5963504

Please sign in to comment.