---
name: "pcap_fileno"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/pcap_fileno"
---

# pcap\_fileno(3)

get the file descriptor for a live capture

## NAME

pcap\_fileno - get the file descriptor for a live capture

## SYNOPSIS

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

**int pcap\_fileno(pcap\_t \*p);**

## DESCRIPTION

If *p* refers to a network device that was opened for a live capture using a combination of [**pcap\_create**(3)](/pcap_create/3.md) and [**pcap\_activate**(3)](/pcap_activate/3.md), or using [**pcap\_open\_live**(3)](/pcap_open_live/3.md), **pcap\_fileno**() returns the file descriptor from which captured packets are read.

If *p* refers to a \`\`savefile'' that was opened using functions such as [**pcap\_open\_offline**(3)](/pcap_open_offline/3.md) or [**pcap\_fopen\_offline**(3)](/pcap_fopen_offline/3.md), a \`\`dead'' **pcap\_t** opened using [**pcap\_open\_dead**(3)](/pcap_open_dead/3.md), or a **pcap\_t** that was created with **pcap\_create**() but that has not yet been activated with **pcap\_activate**(), it returns **PCAP\_ERROR**.

## SEE ALSO

[**pcap**(3)](/pcap/3.md)
