tcpclient
R2026bCreate TCP/IP client connection with TCP/IP server
Description
A tcpclient object represents a connection to a remote host
and remote port from MATLAB® to read and write data. The remote host can be a server or hardware that
supports TCP/IP communication, and must already exist. The tcpclient
object is always the client and cannot be used as a server. For information on creating a
TCP/IP server, see Communicate Using TCP/IP Server Sockets (Instrument Control Toolbox).
Creation
Description
creates a TCP/IP client that connects to a server associated with the remote host
t = tcpclient(address,port)address and remote port port. The value
of address can be either a remote host name or a remote host IP
address. The value of port must be a number between 1 and 65535.
The input address sets the Address
property and the input port sets the Port
property.
If you specified an invalid address or port, the TCP/IP server is not running, or the connection to the server cannot be established, then the object is not created and MATLAB throws an error.
creates a connection and sets additional properties using one or more name-value
pair arguments. Specify each property name, with an equal sign, followed by the
property value. You can set the following properties with a name-value
argument.t = tcpclient(address,port,Name=Value)
ConnectTimeout (Instrument Control Toolbox)
Example: t =
tcpclient("144.212.130.17",80,Timeout=20,ConnectTimeout=30) creates a
TCP/IP client connection to the TCP/IP server on port 80 at IP address
144.212.130.17. It sets the timeout period to 20 seconds and the connection timeout
to 30 seconds.
Properties
Object Functions
read | Read data from remote host over TCP/IP |
readline | Read line of ASCII string data from remote host over TCP/IP |
write | Write data to remote host over TCP/IP |
writeline | Write line of ASCII data to remote host over TCP/IP |
configureTerminator | Set terminator for ASCII string communication with remote host over TCP/IP |
configureCallback | Set callback function and trigger condition for communication with remote host over TCP/IP |
flush | Clear buffers for communication with remote host over TCP/IP |
delete | Delete handle object |
clear | Remove items from workspace, freeing up system memory |