I want to read and write data from OBD2 Wifi enabled Adapter which is used to read car data and fault codes. For that ,I'm using GGCDAsyncSocket Library for socket connection.
You can download CocoaAsyncSocket Library source code
But it maintains connection hardly for 10 seconds and sometimes 40-50 seconds and then terminated.
And the logs shows :
Socket disconnected : Error Domain=NSPOSIXErrorDomain Code=57 "The operation couldn’t be completed. Socket is not connected" UserInfo=0x14cd50 {}
Any help or idea would be appreciated !
Thanks in advance !
Please look at below code :
- (void)connectObdKeyHost:(NSString*)strHost port:(NSString *)strPort {
[gcdAsyncSocket connectToHost:strHost onPort:portNo withTimeout:30 error:&error];
}
// GCDAsyncSocket Delegate Methods
- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port {
NSLog(@"Socket connected : ");
}
- (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err
{
NSLog(@"Socket disconnected : %@",err);
}
I tried with below method :
[gcdAsyncSocket connectToHost:strHost onPort:portNo error:&error];
and now it's working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With