diff --git a/ios/TcpSocketClient.h b/ios/TcpSocketClient.h index 0ba3cba..2ca37b7 100644 --- a/ios/TcpSocketClient.h +++ b/ios/TcpSocketClient.h @@ -57,16 +57,29 @@ typedef enum RCTTCPError RCTTCPError; /// @name Instance Methods ///--------------------------------------------------------------------------------------- /** - * Binds to a host and port + * Connects to a host and port * * @param port * @param host ip address - * @return true if bound, false if there was an error + * @param options NSDictionary which can have @"localAddress" and @"localPort" to specify the local interface + * @return true if connected, false if there was an error */ - (BOOL)connect:(NSString *)host port:(int)port withOptions:(NSDictionary *)options error:(NSError **)error; +/** + * Starts listening on a local host and port + * + * @param local ip address + * @param local port + * @return true if connected, false if there was an error + */ - (BOOL)listen:(NSString *)host port:(int)port error:(NSError **)error; +/** + * Returns the address information + * + * @return NSDictionary with @"address" host, @"port" port, @"family" IPv4/IPv6 + */ - (NSDictionary *)getAddress; /** diff --git a/ios/TcpSocketClient.m b/ios/TcpSocketClient.m index fa78b95..109d82e 100644 --- a/ios/TcpSocketClient.m +++ b/ios/TcpSocketClient.m @@ -230,15 +230,6 @@ NSString *const RCTTCPErrorDomain = @"RCTTCPErrorDomain"; [_clientDelegate onClose:self withError:(!err || err.code == GCDAsyncSocketClosedError ? nil : err)]; } -- (NSError *)badParamError:(NSString *)errMsg -{ - NSDictionary *userInfo = [NSDictionary dictionaryWithObject:errMsg forKey:NSLocalizedDescriptionKey]; - - return [NSError errorWithDomain:RCTTCPErrorDomain - code:RCTTCPBadParamError - userInfo:userInfo]; -} - - (NSError *)badInvocationError:(NSString *)errMsg { NSDictionary *userInfo = [NSDictionary dictionaryWithObject:errMsg forKey:NSLocalizedDescriptionKey]; @@ -248,15 +239,6 @@ NSString *const RCTTCPErrorDomain = @"RCTTCPErrorDomain"; userInfo:userInfo]; } -- (NSError *)sendFailedError:(NSString *)errMsg -{ - NSDictionary *userInfo = [NSDictionary dictionaryWithObject:errMsg forKey:NSLocalizedDescriptionKey]; - - return [NSError errorWithDomain:RCTTCPErrorDomain - code:RCTTCPSendFailedError - userInfo:userInfo]; -} - - (dispatch_queue_t)methodQueue { return dispatch_get_main_queue();