---
name: "pcap_geterr"
section: "3pcap"
platform: "macos"
package: "libpcap"
version: "146"
release: "macOS 26.5"
platforms: ["linux", "macos"]
url: "https://new.carta.tech/pcap_geterr/3pcap"
---

# pcap\_geterr(3pcap)

get or print libpcap error message text

## NAME

pcap\_geterr, pcap\_perror - get or print libpcap error message text

## SYNOPSIS

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

**char \*pcap\_geterr(pcap\_t \*p);** **void pcap\_perror(pcap\_t \*p, const char \*prefix);**

## DESCRIPTION

**pcap\_geterr**() returns the error text pertaining to the last pcap library error. **NOTE**: the pointer it returns will no longer point to a valid error message string after the **pcap\_t** passed to it is closed; you must use or copy the string before closing the **pcap\_t**.

**pcap\_perror**() prints the text of the last pcap library error on **stderr**, prefixed by *prefix*.

## SEE ALSO

**pcap**(3PCAP)
