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

Reply via email to