<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "Event",
  "identifier" : "/documentation/Event/SocketAddress/ipv4(_:port:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Event"
    ],
    "preciseIdentifier" : "s:5Event13SocketAddressV4ipv4_4portACSS_s6UInt16VtKFZ"
  },
  "title" : "ipv4(_:port:)"
}
-->

# ipv4(_:port:)

Creates an IPv4 socket address from a dotted-quad string.

```
static func ipv4(_ host: String, port: UInt16) throws -> SocketAddress
```

## Parameters

`host`

A numeric IPv4 address such as `"127.0.0.1"` or `"192.168.1.1"`. DNS
names are **not** accepted.

`port`

A port number in host byte order (1-65535).

## Return Value

A ready-to-use `SocketAddress` backed by `sockaddr_in`.

## Discussion> Throws: ``doc://Event/documentation/Event/SocketError/invalidAddress(_:)`` if `inet_pton(3)` rejects `host`.

> SeeAlso: ``doc://Event/documentation/Event/SocketAddress/ipv6(_:port:)``, ``doc://Event/documentation/Event/SocketAddress/anyIPv4(port:)``.