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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:16:26+00:00 2026-06-08T21:16:26+00:00

I am trying to connect my iOS application to a printer on a adhoc

  • 0

I am trying to connect my iOS application to a printer on a adhoc network, I need to check the connection is open and valid before sending anything to the printer, How can I achieve this? currently I am doing the following
CFReadStreamRef readStream;
CFWriteStreamRef writeStream;

readStream = NULL;
writeStream = NULL;

CFStreamCreatePairWithSocketToHost(NULL, (__bridge CFStringRef)IPADDRESS, NUM_PORT,NULL ,&writeStream );

if(writeStream)
{
    //inputStream = (__bridge NSInputStream *)readStream;
    oStream = (__bridge NSOutputStream *)writeStream;

    //[iStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    [oStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    //[iStream setDelegate:delegate];
    [oStream setDelegate:delegate];
    //[iStream open];
    [oStream open];
}

and

   int bytesWritten;
   int bytesTotal = [data length];

   bytesWritten = [oStream write:[data bytes] maxLength: bytesTotal];
   NSLog(@"Bytes Written To Printer : %d",bytesWritten);

but it is always going in and writeStream is never null so I am unable to stop it trying to push data to the socket.

~Edit – Maybe I’m best rephrasing my question, How can I stop it from hanging for 30+ seconds until it realises there is no connection?

  • 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-08T21:16:27+00:00Added an answer on June 8, 2026 at 9:16 pm

    I need to check the connection is open and valid before sending anything to the printer, How can I achieve this?

    By sending something to the printer. The only way to detect a connection problem in TCP is to do some I/O with it.

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

Sidebar

Related Questions

I'm trying to upload my iOS application to iTunes Connect. When I run Product->
I'm trying to open a JMX connection to java application running on a remote
I'm trying to create an iOS application which upon loading, will initially connect via
I'm trying to connect to facebook from my iOS application, so I can make
I am trying to write a java application connecting to server connection channel with
I'm trying to build a web application that uses an SSL connection. So I
I'm trying to figure out how to design an iOS app that would connect
I'm trying to establish a HTTP persistent connection from a Silverlight application to a
My application times out while trying to connect to host. The timeout time is
I am trying to make an Http connection in a J2ME application. Problem is

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.