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

  • Home
  • SEARCH
  • 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 8238709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:54:26+00:00 2026-06-07T19:54:26+00:00

I want to make a simples cliente of TCP. But I’m getting one error.

  • 0

I want to make a simples cliente of TCP. But I’m getting one error. When I make inputStream = (NSInputStream *)readStream; and outputStream = (NSOutputStream *)writeStream; it suggests me to introduce the prefix __bridge or _bridge_transfer.

First, what is it? Second, I tried both and still can’t send messages. I followed this tutorial and I’ve the send messages and stream too. I installed Wireshark and the send message is been called, but it’s not sending any packet to the ip.

I’ve just posted here the initNetworkCommunication because is where I get the “bridge” error.

- (void) initNetworkCommunication {

    CFReadStreamRef readStream;
    CFWriteStreamRef writeStream;
    CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"54.xxx.xxx.xxx", 1333, &readStream, &writeStream);

    inputStream = (NSInputStream *)readStream;
    outputStream = (NSOutputStream *)writeStream;
    [inputStream setDelegate:self];
    [outputStream setDelegate:self];
    [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    [inputStream open];
    [outputStream open];

}

The server is fine, because i’ve tried the sample code and I get a response.

Can you help me?

  • 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-07T19:54:28+00:00Added an answer on June 7, 2026 at 7:54 pm

    As H2CO3 mentioned, it’s an ARC thing.

    If you don’t know what ARC is, read this. To summarise, it’s a deterministic way of automating the memory management stuff (retain/release statements etc) that Objective-C programmers previously had to do manually. It’s well worth using, and has few downsides. However, it does have a few gotcha’s.

    ARC doesn’t work on Core Foundation objects. They’re still subject to the old rules, where you have to do the memory management yourself. ARC only applies to Objective-C objects. However, some Core Foundation objects are actually toll-free bridged to their Cocoa equivalent. You’re using toll-free bridging in your code sample, to create a CFReadStreamRef and then work with it as an NSInputStream.

    So what do you do? Apple’s docs say the following:

    If you cast between Objective-C and Core Foundation-style objects, you need to tell the compiler about the ownership semantics of the object using either a cast (defined in objc/runtime.h) or a Core Foundation-style macro (defined in NSObject.h):

    • __bridge transfers a pointer between Objective-C and Core Foundation with no transfer of ownership.
    • __bridge_retained or CFBridgingRetain casts an Objective-C pointer to a Core Foundation pointer and also transfers ownership to you.
      You are responsible for calling CFRelease or a related function to relinquish ownership of the object.
    • __bridge_transfer or CFBridgingRelease moves a non-Objective-C pointer to Objective-C and also transfers ownership to ARC.
      ARC is responsible for relinquishing ownership of the object.

    You’re moving from Core Foundation to Objective-C, so ignore the second bullet point (that’s for going in the other direction). The question is what do you want to happen — if after the transfer you want to hand that object to ARC, use it only from the Objective-C side, and have ARC deal with the memory management, use __bridge_transfer. That’s probably what you want based on your code sample.

    If you just use __bridge, or if you don’t use ARC, you’ll need to clear up the objects yourself, using either CFRelease() or by sending them a release message (the latter only works if you’re not using ARC).

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

Sidebar

Related Questions

I'm a do it yourself kind of guy, but I want to make sure
I always run emacs as daemon but when I want to make something alike
Basically I want to make simple toggle program (that will be mapped to some
I need information about making installation packages for Linux. I want to make simple
I want to make a simple app, where a UIWebView with custom content will
I want to make a simple game: 2d, single-player, without tons of animations and
I want to make a simple game so that I can play against my
I want to make a simple program that sends random keystrokes to my other
I want to make a simple phylogenetic tree for a marine biology course as
I want to make a simple test programm which set the color of the

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.