<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFURLGetPortNumber(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFURLGetPortNumber"
  },
  "title" : "CFURLGetPortNumber(_:)"
}
-->

# CFURLGetPortNumber(_:)

Returns the port number from a given URL.

```
func CFURLGetPortNumber(_ anURL: CFURL!) -> Int32
```

## Parameters

`anURL`

The `CFURL` object to examine.

## Return Value

The port number of `anURL`, or `-1` if no port number exists.

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)