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 7935065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:48:34+00:00 2026-06-03T21:48:34+00:00

I made an application which uses NSStream to etablish a connection to a telnet

  • 0

I made an application which uses NSStream to etablish a connection to a telnet server.
When the connection is made, I send a first command. Then I use sleep(1); to make my application wait. Then the second command is sent.

The problem is that the entire GUI is stuck during the sleep(). I know that it’s not the “perfect” way to make a “pause” and I’d like to learn how to this properly. I heard good things about NSTimer but I’d like to have a concrete and “easy” way of using it, to simply replace my poor use of sleep().

  • 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-03T21:48:36+00:00Added an answer on June 3, 2026 at 9:48 pm

    You should be able to register some kind of callback with whatever procedure you’re using to establish the connection. Just let your code wait for that callback without doing anything at all.

    In this case, using NSStream, you need to schedule the stream on the run loop:

    [stream scheduleInRunLoop:[NSRunLoop currentRunLoop]
                      forMode:NSDefaultRunLoopMode];
    

    The run loop is the construct that processes events for your application. When you use sleep(), it is stopped, and your GUI can’t do anything. By adding the stream as input to the run loop, you allow them both to continue to work.

    You also must set a delegate object ([stream setDelegate:self];, e.g.) which will recieve notifications when the stream has something to report. That delegate must implement stream:handleEvent:, which will be called with a reference to the stream and a code indicating what happened.

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

Sidebar

Related Questions

I made a .net application which uses the Telerik components, so i use the
I have made an application which uses latest ios facebook sdk to connect. I
I've been given a Flex application which made use of a RESTFUL service. I've
Visual Studio 2010 Express, Windows Forms. Have made myself my first little application which
I have an application in which we use a hand-made build system.The reason for
I am working on a GWT application which uses GWT-RPC. I just made a
I have a Winsock based server application which uses Windows Winsock I/O Completion Ports.
I have made a swing application which uses image files located in a folder
I've made a desktop application which uses Cocoa's NSTokenField: alt text http://developer.apple.com/documentation/Cocoa/Conceptual/TokenField_Guide/Art/tokenfield.jpg More info
I have made an application in which there is a file main.c which uses

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.