thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sewon <right...@gmail.com>
Subject reconnecting cocoa client
Date Fri, 08 Jul 2011 06:16:45 GMT
I'm using thrift 0.2 version with below

server: java
client: cocoa touch (iphone)

All connections and transporting data are successful. But I don't know how to clear socket
or reconnecting on cocoa
It means that when the application resign active, I want to close the connection and then
reconnect to the server when becoming active. 

simply, I tested like below

-(void)connect:(NSString*)ip serverPort:(NSUInteger)portNum {
    
    transport = [[TSocketClient alloc] initWithHostname:ip 
                                                   port:portNum];
    protocol = [[TBinaryProtocol alloc] initWithTransport:transport
                                               strictRead:YES 
                                              strictWrite:YES];
    service = [[serverDBIOServiceClient alloc] initWithProtocol:protocol];
}

-(void)reconnect {
    [transport initWithHostname:serverIP port:serverPort];
    [protocol initWithTransport:transport  strictRead:YES strictWrite:YES];
    service = [service initWithProtocol:protocol];
}

-(void)disconnect {
    [service release];
    [protocol release];
    [transport release];
    service = nil;
}

Is it right? it almost has been fine on test. but sometimes crashed
Please show me good examples.

thanks in advance
Sewon Na
Mime
View raw message