• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Help creating CFSocket
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help creating CFSocket


  • Subject: Re: Help creating CFSocket
  • From: Rick Mann <email@hidden>
  • Date: Tue, 26 Oct 2010 02:29:01 -0700

On Oct 26, 2010, at 02:25:25, Quinn The Eskimo! wrote:

> I can see a bunch of problems here, all centred around the following:
>
>> NSData* addrData = [NSData dataWithBytes: addr4 length: addr4->sin_len];
>> addr4->sin_port = 123;
>> sig.address = (CFDataRef) addrData;
>
> 1. You should fill out all the fields of addr4, not just sin_addr and sin_port.  Specifically, you should fill out sin_family and sin_len.

Ah. I was of the mindset that those were already set by the CFHost resolution stuff.

> 2. sin_port should be in network byte order; you need a htons() here.

Right! I've seen that in the example code.

> 3. When you create addrData you take an immutable snapshot of addr4.  Changes to addr4 after that won't be effective.  You need to fully set up addr4 before creating addrData.

Well, that was just dumb.

Thanks for being up!

--
Rick

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Help creating CFSocket (From: Rick Mann <email@hidden>)
 >Re: Help creating CFSocket (From: "Quinn \"The Eskimo!\"" <email@hidden>)

  • Prev by Date: Re: Help creating CFSocket
  • Previous by thread: Re: Help creating CFSocket
  • Index(es):
    • Date
    • Thread