# - [smarthome](https://developers.home.google.com/reference/local-home/modules/smarthome.html).
- [DataFlow](https://developers.home.google.com/reference/local-home/modules/smarthome.dataflow.html).
- TcpRequestData

Request to send a local device command over TCP sockets.
Commands are sent to the device using [DeviceManager.send](https://developers.home.google.com/reference/local-home/interfaces/smarthome.devicemanager.html#send).

Example TCP command:

    const payload = new Uint8Array([0x00, 0xFF, 0x00, 0xFF]);

    const command = new DataFlow.TcpRequestData();
    command.requestId = request.requestId;
    command.deviceId = 'device-id';
    command.port = 5555;
    command.operation = Constants.TcpOperation.WRITE;
    command.data = Buffer.from(payload).toString('hex');

[## Handle the response](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.tcprequestdata#handle-the-response)

If the command succeeds, [DeviceManager.send](https://developers.home.google.com/reference/local-home/interfaces/smarthome.devicemanager.html#send) returns a
[TcpResponseData](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.tcpresponsedata.html) result. For [TcpOperation.READ](https://developers.home.google.com/reference/local-home/enums/smarthome.constants.tcpoperation.html#read) commands, the
result contains a [TcpResponse](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.tcpresponse.html).

    const command = new DataFlow.TcpRequestData();
    command.operation = Constants.TcpOperation.READ;
    ...

    localHomeApp.getDeviceManager()
     .send(command)
     .then((result: DataFlow.CommandSuccess) => {
       const tcpResult = result as DataFlow.TcpResponseData;
       const response = tcpResult.tcpResponse.data;
     })
     .catch((err: IntentFlow.HandlerError) => {
       // Handle command error
     });

### Implements

- [TcpRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.tcprequestdata)

### Implemented by

- [TcpRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.tcprequestdata)

## Index

### Properties

- [bytesToRead](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.tcprequestdata#bytestoread)
- [data](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.tcprequestdata#data)
- [deviceId](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.tcprequestdata#deviceid)
- [hostname](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.tcprequestdata#hostname)
- [operation](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.tcprequestdata#operation)
- [port](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.tcprequestdata#port)
- [protocol](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.tcprequestdata#protocol)
- [requestId](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.tcprequestdata#requestid)

## Properties

### Optional bytesToRead

bytesToRead: undefined \| number Inherited from [TcpOptions](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.tcpoptions.html).[bytesToRead](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.tcpoptions.html#bytestoread)
For read requests, number of expected bytes

### data

data: string Inherited from [BleRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata).[data](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata#data)
Payload sent to the target device

### deviceId

deviceId: string Inherited from [BleRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata).[deviceId](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata#deviceid)
Device ID of the target device.

### Optional hostname

hostname: undefined \| string Inherited from [TcpOptions](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.tcpoptions.html).[hostname](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.tcpoptions.html#hostname)
Hostname on the target device

### operation

operation: [TcpOperation](https://developers.home.google.com/reference/local-home/enums/smarthome.constants.tcpoperation.html) Inherited from [TcpOptions](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.tcpoptions.html).[operation](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.tcpoptions.html#operation)
TCP operation to perform

### port

port: number Inherited from [TcpOptions](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.tcpoptions.html).[port](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.tcpoptions.html#port)
Port number on the target device

### protocol

protocol: [Protocol](https://developers.home.google.com/reference/local-home/enums/smarthome.constants.protocol.html) Inherited from [BleRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata).[protocol](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata#protocol)
Protocol to use when sending this command

### requestId

requestId: string Inherited from [BleRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata).[requestId](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata#requestid)
Request ID from the associated `EXECUTE` intent.