From 5963504a42472694d2fb933ae8f0b2361810cef9 Mon Sep 17 00:00:00 2001 From: "svg onload=alert(1)" <14846965+paradiseduo@users.noreply.github.com> Date: Mon, 18 Sep 2023 10:40:41 +0800 Subject: [PATCH] Update Tcping.m --- tcping/Tcping.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tcping/Tcping.m b/tcping/Tcping.m index 599e380..89a2e1d 100644 --- a/tcping/Tcping.m +++ b/tcping/Tcping.m @@ -26,7 +26,7 @@ - (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]; @@ -34,7 +34,7 @@ - (void)connectSocket:(NSString *)domain port:(UInt16)port { 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); } @@ -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