Write data to remote host over TCP/IP
Create a TCP/IP object called
to a TCP/IP echo server, with Port of
7. This requires
you to have an
echotcpip server running on Port
t = tcpclient('localhost', 7)
t = tcpclient with properties: Address: 'local host' Port: 7 Timeout: 10 BytesAvailable: 0
write function synchronously writes data
to the remote host connected to the
First specify the data, then write the data. The function waits until
the specified number of values is written to the remote host.
Assign 10 bytes of
uint8 data to the
data = uint8(1:10)
data = 1 2 3 4 5 6 7 8 9 10
Check the data.
Name Size Bytes Class Attributes data 1x10 10 uint8
Write data to the echo server.
Check that the data was written using the
ans = 10
Read the data from the server.
ans = 1 2 3 4 5 6 7 8 9 10
Close the connection between the TCP/IP client object and the remote host by clearing the object.
data— Data to write to the remote host
Data to write to the remote host, specified as a 1xN matrix of numeric data.