---
updatedAt: 2026-02-03T02:47:43.000Z
agentTools:
  projectIndex: https://lan.developer.lifx.com/llms.txt
---

# Communicating with a device

All LIFX packets are sent over `UDP` to each device on port `56700`. `UDP` is a state-less protocol where you send bytes to a remote destination without first making a specific connection to the destination. If the device you sent bytes to decides to send information back, your `UDP` socket will receive those bytes.

There are five scenarios with sending packets to a device:

* Broadcasting a message to everything on the network (i.e. discovery)
* Sending a message and getting back just an `Acknowledgment`
* Sending a message and getting back just a `State` message
* Sending a message and getting both an `Acknowledgement` and a `State` message
* Sending a message and getting no reply

## Discovery

There are two supported forms of discovery for LIFX devices. Broadcast discovery is supported on all devices, while mDNS-based discovery is only supported on newer devices. mDNS discovery is more efficient and should always be the first choice if you don't need to work with older devices.

### Broadcast Discovery

1. Send [GetService (2)](https://lan.developer.lifx.com/docs/querying-the-device-for-data#getservice---packet-2) as a UDP broadcast to port 56700 with the [Frame Header](https://lan.developer.lifx.com/docs/packet-contents#frame-header) `tagged` field set to `1`.
2. All devices on LAN should respond back with one or more [StateService (3)](https://lan.developer.lifx.com/docs/information-messages#stateservice---packet-3) messages.
3. Clients can then send further messages directly to individual devices or broadcast them.

<Image alt="579" border={false} src="https://files.readme.io/I7URyKh8SLuvpdyc9QOj_discovery.png" title="discovery.png" />

### mDNS Discovery

mDNS discovery relies on a custom [Multicast DNS](https://en.wikipedia.org/wiki/Multicast_DNS) service, that is provided by all LIFX devices running firmware 4.110 or higher. This is the new method of LIFX device discovery, and will be the preferred method going forward.

The LIFX mDNS service is `_lifx._udp` and it provides several TXT record values to allow for quickly identifying what kind of device it is.

* `id` Serial number of the device. This should always be used instead of looking at the service name (You cannot assume the service name will always match the serial number)
* `fw` Semantic version of current firmware (e.g. 4.110)
* `p` Product ID of the device

## Request with acknowledgement

1. Discover devices as above.
2. Set the source field with a unique 32-bit number, it does not have to be globally unique.
3. Use the wrap around `sequence` as a message ID.
4. Set the `ack_required` field to `1`
5. Send message and it is acknowledged with [Acknowledgement (45)](https://lan.developer.lifx.com/docs/information-messages#acknowledgement---packet-45) having same source and sequence.

Note that Get messages will also send back a State response, even if the `res_required` field is set to `0`.

<Image alt="904" border={false} src="https://files.readme.io/Q4COCrwzT2Oa2QRDahtV_request-with-ack.png" title="request-with-ack.png" />

## Request with response

1. Discover devices as above.
2. Set the `source` field with a unique 32-bit number, it does not have to be globally unique.
3. Use the wrap around `sequence` as a message ID.
4. Send a Get message and/or set the `res_required` field to `1`
5. Send message and a corresponding semantic reply is sent back having same source and sequence.

We recommend not relying on `State` messages when you send a `Set` message as the `State` is likely the state before the change.

<Image alt="871" border={false} src="https://files.readme.io/tzQlY64rQXyCDD6WTeBP_request-with-response.png" title="request-with-response.png" />

## Request with acknowledgement and response

When a request receives a State message and also requests an acknowledgement, the ack will be sent to you just before the device processes the message.

<Image alt="908" border={false} src="https://files.readme.io/7mjfsOoZRheFQzv7IBgC_request-with-ack-and-response.png" title="request-with-ack-and-response.png" />

## Request without acknowledgement or response

If you send a packet with `ack_required` and `res_required` set to `false` and the message is not a `Get` message: then your device may or may not receive your packet and no response will be sent back to you. In this case you may want to query the device at some point in the future to determine if your packet had an impact on the device.