---
name: "TSfwrite"
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/TSfwrite"
---

# TSfwrite(3ts)

TSfwrite API function

## NAME

TSfwrite - TSfwrite API function

## SYNOPSIS

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

- **ssize\_t TSfwrite(*TSFile* filep, const void \*buf, size\_t length)**

  ## DESCRIPTION

Attempts to write *length* bytes of data from the buffer *buf* to the file *filep*.

Make sure that *filep* is open for writing.  You might want to check the number of bytes written (*TSfwrite()* returns this value) against the value of *length*.  If it is less, there might be insufficient space on disk, for example.

The behavior is undefined if length is greater than SSIZE\_MAX.

## RETURN VALUE

Returns the number of bytes actually written, or -1 if an error occurred.

## COPYRIGHT

2026, dev@trafficserver.apache.org
