---
name: "TSHttpTxnServerAddrSet"
section: "3ts"
platform: "linux"
package: "trafficserver-dev"
version: "9.2.5+ds-0+deb12u4"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/TSHttpTxnServerAddrSet"
---

# TSHttpTxnServerAddrSet(3ts)

TSHttpTxnServerAddrSet API function

## NAME

TSHttpTxnServerAddrSet - TSHttpTxnServerAddrSet API function

## SYNOPSIS

```
#include <ts/ts.h>
```

- ***TSReturnCode* TSHttpTxnServerAddrSet(*TSHttpTxn* txnp, struct sockaddr const \*addr)**

  ## DESCRIPTION

Set the origin server address for transaction *txnp*. This includes the port in *addr*. The address family is also set by the contents of *addr*. The address data is copied out of *addr* so there is no dependency on the lifetime of that object.

This hook must be called no later than TS\_HTTP\_OS\_DNS\_HOOK. If this is called prior to TS\_HTTP\_OS\_DNS\_HOOK, DNS resolution will not be done as the address of the server is already known.

## RETURN VALUE

*TS\_ERROR* is returned if *addr* does not contain a valid IPv4 or IPv6 address with a valid (non-zero) port.

## NOTES

If Traffic Server is configured to retry connections to origin servers and *TSHttpTxnServerAddrGet()* has been called, Traffic Server will return to TS\_HTTP\_OS\_DNS\_HOOK so to let the plugin set a different server address. Plugins should be prepared for TS\_HTTP\_OS\_DNS\_HOOK and any subsequent hooks to be called multiple times.

Once a plugin calls *TSHttpTxnServerAddrGet()* any prior DNS resolution results are lost. The plugin should use *TSHttpTxnServerAddrGet()* to preserve any DNS Results that might need.

## SEE ALSO

**[TSAPI(3ts)](/TSAPI/3ts.md)**, **[TSHttpTxnServerAddrGet(3ts)](/TSHttpTxnServerAddrGet/3ts.md)**

## COPYRIGHT

2026, dev@trafficserver.apache.org
