ios - GCDAsyncSockets, get answer -


i'm trying test server connection gcdasyncsocket.

https://github.com/robbiehanson/cocoaasyncsocket

i want connect ip + port , message, whether worked, or not.

i'm far right now.

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions 

{ // override point customization after application launch.

dispatch_queue_t mainqueue = dispatch_get_main_queue();  asyncsocket = [[gcdasyncsocket alloc] initwithdelegate:self delegatequeue:mainqueue];       nsstring *host = @"www.google.de";     uint16_t port = 21;      nserror *error = nil;      if(![asyncsocket connecttohost:host onport:port error:&error])     {         nslog(@"error %@!!!", error);     }     else{         nslog(@"no error %@!!!", error);     }      [asyncsocket writedata:@"data" withtimeout:3 tag:0];  return yes; 

}

but how can check whether data written or not?

if(![asyncsocket connecttohost:host onport:port error:&error])

always me no error.

you have implement socket:didwritedatawithtag: delegate method. "gcdasyncsocket.h":

/**  * called when socket has completed writing requested data. not called if there error. **/ - (void)socket:(gcdasyncsocket *)sock didwritedatawithtag:(long)tag; 

if write times out connection closed , delegate method

- (void)socketdiddisconnect:(gcdasyncsocket *)sock witherror:(nserror *)err; 

is called.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -