• 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: Problems with SCNetworkConnection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with SCNetworkConnection


  • Subject: Re: Problems with SCNetworkConnection
  • From: Quinn <email@hidden>
  • Date: Thu, 7 Oct 2004 17:51:08 +0100

Title: Re: Problems with SCNetworkConnection
At 10:27 +0200 14/9/04, Ralf Menssen wrote:
I'm writing an application that directly connects to the internet using our settings (not an illegal diealer!).

I guess I'll take your word for it (-:
There in ran into two problems:

1. a call to

SCNetworkConnectionCopyUserPreferences (NULL, &serviceID, &userOptions)

returns a good serviceID, but what I really want are the userOptions, to see their content. But userOptions are NULL.

This is expected.  Most users don't have user-specific options that override the settings in the service, and thus userOptions comes back as NULL.  It's possible to get userOptions come back as non-NULL, but tricky.  I explained this on the list a few months ago.

At 12:27 +0100 10/8/04, Quinn wrote:
Yes, that's perfectly normal.  What it means is that you haven't used Internet Connect to override any settings defined in Network preferences.

If you want to see this dictionary in action, do the following.

1. Launch Internet Connect.

2. From the Configuration popup, choose Edit Configurations.

3. In the resulting dialog, click the plus button to create a new configuration.

4. Enter "Secondary" into the Description field (just so you can keep track).

5. In the Configurations list, drag "Secondary" above "Main Number".

6. Click OK to dismiss the dialog.

7. Quit Internet Connect.

The next time you call SCNetworkConnectionCopyUserPreferences, userOptions should come back as a real dictionary containing the settings associated with "Secondary".

[It took me at least half an hour's work (and looking at the source!) to figure out how this worked.  *sigh*  It's just not obvious that the configuration listed at the top of the Configurations list is the significant one.  I've filed <rdar://problem/3756804> to request a better UI.]

If I try to get them later:
mhsDictionary = SCNetworkConnectionCopyUserOptions (gConnection);

I get a value, but accessing it e.g. with CFDictionaryGetCount results in a bus error.

I don't know what's causing this, but as you're only doing it because of problems 1 and 2, I'm not going to worry.

2. To setup the connection I need a dictionary. This dictionary in not one-dimensional, but contains <dict> statements as one can see in the documentation. But I have not found any example and no word in the documentation, how to create sub-dictionaries. Always just the trivial keys/values examples.

userOptions is a dictionary.  Each element of the dictionary is itself a dictionary that contains the override settings for one particular entity.  So, for example, let's say you want to override the phone number and the modem speaker setting.  The dictionary you'd create would be:

  userOptions
    PPP
      kSCPropNetPPPCommRemoteAddress = "12345678"
    Modem
      kSCPropNetModemSpeaker = 0

These settings are merged into the settings from the persistent store (that is, the network service identified by serviceID) and that's what's used for the connection.

S+E
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Technical Support * Networking, Communications, Hardware
 _______________________________________________
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

  • Prev by Date: RE: Internet/Network Settings
  • Next by Date: Re: OT UDP received IP address has changed
  • Previous by thread: RE: Internet/Network Settings
  • Next by thread: Re: OT UDP received IP address has changed
  • Index(es):
    • Date
    • Thread