# PacketInfo

<a id="packetinfo"></a>

# PacketInfo

```cpp
#include <icy/net/socket.h>

struct PacketInfo
```

[Defined in src/net/include/icy/net/socket.h:155](https://github.com/auscaster/icey/blob/main/src/net/include/icy/net/socket.h#L155)

> **Inherits:** [`IPacketInfo`](https://auscaster.com/icey/docs/api-reference/icy-IPacketInfo.md#ipacketinfo)

Provides information about packets emitted from a socket. See [SocketPacket](https://auscaster.com/icey/docs/api-reference/icy-net-SocketPacket.md#socketpacket).

## List of all members

| Name | Kind | Owner |
|------|------|-------|
| [`socket`](#socket) | `variable` | Declared here |
| [`peerAddress`](#peeraddress) | `variable` | Declared here |
| [`PacketInfo`](#packetinfo-1) | `function` | Declared here |
| [`PacketInfo`](#packetinfo-2) | `function` | Declared here |
| [`clone`](#clone-9) | `function` | Declared here |
| [`~PacketInfo`](#packetinfo-3) | `function` | Declared here |
| [`IPacketInfo`](https://auscaster.com/icey/docs/api-reference/icy-IPacketInfo.md#ipacketinfo-1) | `function` | Inherited from [`IPacketInfo`](https://auscaster.com/icey/docs/api-reference/icy-IPacketInfo.md#ipacketinfo) |
| [`~IPacketInfo`](https://auscaster.com/icey/docs/api-reference/icy-IPacketInfo.md#ipacketinfo-2) | `function` | Inherited from [`IPacketInfo`](https://auscaster.com/icey/docs/api-reference/icy-IPacketInfo.md#ipacketinfo) |
| [`clone`](https://auscaster.com/icey/docs/api-reference/icy-IPacketInfo.md#clone-2) | `function` | Inherited from [`IPacketInfo`](https://auscaster.com/icey/docs/api-reference/icy-IPacketInfo.md#ipacketinfo) |

## Inherited from [`IPacketInfo`](https://auscaster.com/icey/docs/api-reference/icy-IPacketInfo.md#ipacketinfo)

| Kind | Name | Description |
|------|------|-------------|
| `function` | [`IPacketInfo`](https://auscaster.com/icey/docs/api-reference/icy-IPacketInfo.md#ipacketinfo-1)  | Defaulted constructor. |
| `function` | [`~IPacketInfo`](https://auscaster.com/icey/docs/api-reference/icy-IPacketInfo.md#ipacketinfo-2) `virtual` | Defaulted destructor. |
| `function` | [`clone`](https://auscaster.com/icey/docs/api-reference/icy-IPacketInfo.md#clone-2) `virtual` `const` | Returns a heap-allocated deep copy of this info object. |

## Public Attributes

| Return | Name | Description |
|--------|------|-------------|
| [`Socket::Ptr`](https://auscaster.com/icey/docs/api-reference/icy-net-Socket.md#ptr-9) | [`socket`](#socket)  | The source socket. |
| [`Address`](https://auscaster.com/icey/docs/api-reference/icy-net-Address.md#address) | [`peerAddress`](#peeraddress)  | The originating peer address. For TCP this will always be connected address. |

---

<a id="socket"></a>

### socket

```cpp
Socket::Ptr socket
```

Type: [`Socket::Ptr`](https://auscaster.com/icey/docs/api-reference/icy-net-Socket.md#ptr-9)

[Defined in src/net/include/icy/net/socket.h:158](https://github.com/auscaster/icey/blob/main/src/net/include/icy/net/socket.h#L158)

The source socket.

---

<a id="peeraddress"></a>

### peerAddress

```cpp
Address peerAddress
```

Type: [`Address`](https://auscaster.com/icey/docs/api-reference/icy-net-Address.md#address)

[Defined in src/net/include/icy/net/socket.h:162](https://github.com/auscaster/icey/blob/main/src/net/include/icy/net/socket.h#L162)

The originating peer address. For TCP this will always be connected address.

## Public Methods

| Return | Name | Description |
|--------|------|-------------|
|  | [`PacketInfo`](#packetinfo-1) `inline` | Constructs [PacketInfo](#packetinfo) with the originating socket and peer address. |
|  | [`PacketInfo`](#packetinfo-2) `inline` | Copy constructor. |
| std::unique_ptr< [`IPacketInfo`](https://auscaster.com/icey/docs/api-reference/icy-IPacketInfo.md#ipacketinfo) > | [`clone`](#clone-9) `virtual` `const` `inline` | Returns a heap-allocated copy of this [PacketInfo](#packetinfo). |
|  | [`~PacketInfo`](#packetinfo-3) `virtual` `noexcept` | Defaulted destructor. |

---

<a id="packetinfo-1"></a>

### PacketInfo

`inline`

```cpp
inline PacketInfo(const Socket::Ptr & socket, const Address & peerAddress)
```

[Defined in src/net/include/icy/net/socket.h:167](https://github.com/auscaster/icey/blob/main/src/net/include/icy/net/socket.h#L167)

Constructs [PacketInfo](#packetinfo) with the originating socket and peer address.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `socket` | const [`Socket::Ptr`](https://auscaster.com/icey/docs/api-reference/icy-net-Socket.md#ptr-9) & | Shared pointer to the socket that received the packet. |
| `peerAddress` | const [`Address`](https://auscaster.com/icey/docs/api-reference/icy-net-Address.md#address) & | [Address](https://auscaster.com/icey/docs/api-reference/icy-net-Address.md#address) of the remote peer that sent the packet. |

---

<a id="packetinfo-2"></a>

### PacketInfo

`inline`

```cpp
inline PacketInfo(const PacketInfo & r)
```

[Defined in src/net/include/icy/net/socket.h:175](https://github.com/auscaster/icey/blob/main/src/net/include/icy/net/socket.h#L175)

Copy constructor.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `r` | const [`PacketInfo`](#packetinfo) & | Source [PacketInfo](#packetinfo) to copy from. |

---

<a id="clone-9"></a>

### clone

`virtual` `const` `inline`

```cpp
virtual inline std::unique_ptr< IPacketInfo > clone() const
```

[Defined in src/net/include/icy/net/socket.h:182](https://github.com/auscaster/icey/blob/main/src/net/include/icy/net/socket.h#L182)

Returns a heap-allocated copy of this [PacketInfo](#packetinfo).

#### Reimplements

- [`IPacketInfo::clone`](https://auscaster.com/icey/docs/api-reference/icy-IPacketInfo.md#clone-2)

---

<a id="packetinfo-3"></a>

### ~PacketInfo

`virtual` `noexcept`

```cpp
virtual ~PacketInfo() noexcept = default
```

[Defined in src/net/include/icy/net/socket.h:184](https://github.com/auscaster/icey/blob/main/src/net/include/icy/net/socket.h#L184)

Defaulted destructor.
