Read one binblock of data sent to TCP/IP server
reads a binblock of data sent to the TCP/IP server
data = readbinblock(
t from the client
connected to it and returns the data as a row vector of doubles. The function suspends
MATLAB® execution until the number of values specified in the binblock is read or a
Create a TCP/IP server that listens for connections at
localhost and port 4000.
server = tcpserver("localhost",4000)
server = TCPServer with properties: ServerAddress: "127.0.0.1" ServerPort: 4000 Connected: 0 ClientAddress: "" ClientPort:  NumBytesAvailable: 0 Show all properties, functions
Create a TCP/IP client to connect to your server object using
tcpclient. You must specify the same IP address and port number you use to create
client = tcpclient("localhost",4000)
client = tcpclient with properties: Address: 'localhost' Port: 4000 NumBytesAvailable: 0 Show all properties, functions
Write a binblock of data to the client in
Since the client is connected to the server, the data you write to the client is available to be read from the
server object. Read the binblock of data.
ans = 1×6 4 8 15 16 23 42
If you write a binblock of data to the client that is not in
uint8 format, you must specify the data type when reading it from the
writebinblock(client,"Hello, world!","string") readbinblock(server,"string")
ans = "Hello, world!"
t— TCP/IP server
TCP/IP server, specified as a
readbinblock(t) reads a binblock of data sent to the
t from the client connected to it.
datatype— Size and format of each value
Size and format of each value, specified as a character vector or string.
datatype determines the number of bytes to read for each value
and the interpretation of those bytes as a MATLAB data type.
readbinblock(t,"double") reads a binblock of double