---
title: "CFSocketSetAddress(_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfsocketsetaddress(_:_:)"
---

# CFSocketSetAddress(_:_:)

Binds a local address to a CFSocket object and configures it for listening.

## Declaration

```swift
func CFSocketSetAddress(_ s: CFSocket!, _ address: CFData!) -> CFSocketError
```

## Parameters

- `s`: The CFSocket object to modify.
- `address`: A CFData object containing a struct sockaddr appropriate for the protocol family of s (struct sockaddr_in or struct sockaddr_in6, for example). This data object is used only for the duration of the function call.

## Return Value

Return Value An error code indicating success or failure.

## Discussion

Discussion This function binds the socket by calling bind, and if the socket supports it, configures the socket for listening by calling listen with a backlog of 256. Once s is bound to address, depending on the socket’s protocol, other processes and computers can connect to s.

## See Also

### Configuring Sockets

- [CFSocketCopyAddress(_:)](corefoundation/cfsocketcopyaddress(_:).md)
- [CFSocketCopyPeerAddress(_:)](corefoundation/cfsocketcopypeeraddress(_:).md)
- [CFSocketDisableCallBacks(_:_:)](corefoundation/cfsocketdisablecallbacks(_:_:).md)
- [CFSocketEnableCallBacks(_:_:)](corefoundation/cfsocketenablecallbacks(_:_:).md)
- [CFSocketGetContext(_:_:)](corefoundation/cfsocketgetcontext(_:_:).md)
- [CFSocketGetNative(_:)](corefoundation/cfsocketgetnative(_:).md)
- [CFSocketGetSocketFlags(_:)](corefoundation/cfsocketgetsocketflags(_:).md)
- [CFSocketSetSocketFlags(_:_:)](corefoundation/cfsocketsetsocketflags(_:_:).md)
