Class

# Datagram

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to send and receive data using the `UDPSocket</api/networking/udpsocket>` class.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                        | Type                               | Read-Only | Shared |
|-----------------------------|------------------------------------|-----------|--------|
| `Address<datagram.address>` | `String</api/data_types/string>`   |           |        |
| `Data<datagram.data>`       | `String</api/data_types/string>`   |           |        |
| `Port<datagram.port>`       | `Integer</api/data_types/integer>` |           |        |

## Property descriptions

<div id="datagram.address">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Datagram.Address

**Address** As `String</api/data_types/string>`

> The address of the remote machine that you are sending data to, or receiving data from.
>
> ``` xojo
> d.Address = "192.168.1.10"
> ```

<div id="datagram.data">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Datagram.Data

**Data** As `String</api/data_types/string>`

> The data you are sending or receiving.
>
> ``` xojo
> d.Data = "Hello world"
> ```

<div id="datagram.port">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Datagram.Port

**Port** As `Integer</api/data_types/integer>`

> The port that the packet will be sent to when calling the Write method. If the Port property is set or left to zero, then the port that it is locally bound to is used.
>
> When reading packets, the Port property specifies the port that the <span class="title-ref">Datagram</span> was sent from on the remote computer.
>
> ``` xojo
> d.Port = 7080
> ```

## Notes

A <span class="title-ref">Datagram</span> consists of two parts, the IP address of the remote machine which sent you the data, and the data itself. When you attempt to send data, you must specify information in the form of a <span class="title-ref">Datagram</span>. This information is usually the remote address of the machine you want to receive your packet, the port it should be sent to, and the data you wish to send the remote machine. Please see the `UDPSocket</api/networking/udpsocket>` for information on how to use the <span class="title-ref">Datagram</span>.

## Compatibility

|                       |                               |
|-----------------------|-------------------------------|
| **Project Types**     | Console, Desktop, Mobile, Web |
| **Operating Systems** | iOS, Linux, macOS, Windows    |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `SocketCore</api/networking/socketcore>`, `UDPSocket</api/networking/udpsocket>` classes

</div>
