Main Content

TCP/IP Communication

Read and write data over TCP/IP interface

Transmission Control Protocol (TCP) is a transport protocol layered on top of the Internet Protocol (IP) and is one of the most used networking protocols. MATLAB® support for TCP/IP client communication enables you to use network socket communication to connect to remote hosts from MATLAB for reading and writing both binary and ASCII data.

Use tcpclient to create a TCP/IP client that connects to a server or hardware and perform read and write operations.

Functions

expand all

tcpclientCreate TCP/IP client connection with TCP/IP server
echotcpipStart or stop TCP/IP echo server
configureTerminatorSet terminator for ASCII string communication with remote host over TCP/IP (Since R2020b)
configureCallbackSet callback function and trigger condition for communication with remote host over TCP/IP (Since R2020b)
readRead data from remote host over TCP/IP
readlineRead line of ASCII string data from remote host over TCP/IP (Since R2020b)
writeWrite data to remote host over TCP/IP
writelineWrite line of ASCII data to remote host over TCP/IP (Since R2020b)
flushClear buffers for communication with remote host over TCP/IP (Since R2020b)

Apps

TCP/IP ExplorerConnect to and communicate with TCP/IP server (Since R2021b)
Hardware ManagerDiscover and get started with your hardware (Since R2022a)

Topics

Troubleshooting

Troubleshooting TCP/IP Client Interface

Troubleshoot the TCP/IP client interface.

Resolve TCP/IP Client Connection Errors

Troubleshoot creating a TCP/IP client.

Resolve TCP/IP Client Warning: Unable to Read Any Data

Troubleshoot when you receive no data and you get the warning message: 'tcpclient' unable to read any data.