Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8033855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:49:54+00:00 2026-06-05T01:49:54+00:00

I am using the CocoaAsyncSockets library in order to create a tcp socket connection

  • 0

I am using the CocoaAsyncSockets library in order to create a tcp socket connection in my app. Currently, I have successfully created a connection by opening the socket connection in my didFinishLaunchingWithOptions method in my appDelegate.m file. My code looks like 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 for 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 my connect method:

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

Now, what I have been struggling with is how to use read/write methods in my views without having to re-establish a connection.

  • I have established a tcp socket connection when the application launches
  • I open the socket in the didFinishLaunchWithOptions method so that I can create the connection and stay connected the entire time my app is running
  • I don’t know how to read/write from/to the server from my views
  • I’m very new to socket/iOS development, so I’m hoping for the easiest possible solution

I would appreciate any help I can get on this. I’m still pretty new to iOS and still picking up on the syntax, so the more details anyone can provide, the better off I’ll be.

Thanks so much for the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:49:57+00:00Added an answer on June 5, 2026 at 1:49 am

    AsyncSocket comes with this method for writing:

    - (void)writeData:(NSData *)data withTimeout:(NSTimeInterval)timeout tag:(long)tag;
    

    And several variants of read methods, here is one: (more from the header file of the library)

    - (void)readDataWithTimeout:(NSTimeInterval)timeout tag:(long)tag;
    

    You should get the samples code from the same website that you have downloaded the AsyncSocket library to see how they are used. One thing to keep in mind is that these methods are asynchronous operations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a TCP Socket connection in my appDelegate didFinishLaunchingWithOptions method. That was
I have created a TCP Sockets connection using CocoaAsyncSocket and whenever I try to
Using android 2.3.3, I have a background Service which has a socket connection. There's
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
Using Entity Framework CodeFirst, how do I create a created datetime column that gets
Using Google Maps InfoBox - http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html Currently the map will scroll - pan control
Using boost python I need create nested namespace. Assume I have following cpp class
I need some help in IOS Socket programming. I have implemented a successful TCP
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
Using C# for ASP.NET and MOSS development, we often have to embed JavaScript into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.