iphone - CocoaAsyncSockets creating Connection on app startup but Reading/Writing from a view(s) -


i using cocoaasyncsockets library in order create tcp socket connection in app. currently, have created connection opening socket connection in didfinishlaunchingwithoptions method in appdelegate.m file. code looks so:

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:  (nsdictionary *)launchoptions {     socket = [[asyncsocket alloc] initwithdelegate:self];     [self connect];      self.window = [[[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]    autorelease];     // override point customization after application launch.     self.viewcontroller = [[[tekmatrixviewcontroller alloc]     initwithnibname:@"tekmatrixviewcontroller" bundle:nil] autorelease];     self.window.rootviewcontroller = self.viewcontroller;     [self.window makekeyandvisible];     return yes; } 

and here's connect method:

- (void)connect  {     [socket connecttohost:@"9.5.3.6" onport:11005 error:nil]; } 

now, have been struggling how use read/write methods in views without having re-establish connection.

  • i have established tcp socket connection when application launches
  • i open socket in didfinishlaunchwithoptions method can create connection , stay connected entire time app running
  • i don't know how read/write from/to server views
  • i'm new socket/ios development, i'm hoping easiest possible solution

i appreciate can on this. i'm still pretty new ios , still picking on syntax, more details can provide, better off i'll be.

thanks help!

asyncsocket comes method writing:

- (void)writedata:(nsdata *)data withtimeout:(nstimeinterval)timeout tag:(long)tag; 

and several variants of read methods, here one: (more header file of library)

- (void)readdatawithtimeout:(nstimeinterval)timeout tag:(long)tag; 

you should samples code same website have downloaded asyncsocket library see how used. 1 thing keep in mind these methods asynchronous operations.


Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -