フィルターのクリア

it meet errors when I use read(t)#TCP/ip

24 ビュー (過去 30 日間)
承武
承武 2023 年 2 月 28 日
コメント済み: 承武 2023 年 3 月 15 日
could you help me?why does it meet errors when I use read(t)
clc;
clear
%% 主机端
% echotcpip("on",5000)
[~,hostname] = system('hostname');
hostname = string(strtrim(hostname));
address = resolvehost(hostname,"address");
server = tcpserver(address,5000,"ConnectionChangedFcn",@connectionFcn);
configureCallback(server,"off")
server.NumBytesAvailable
%% 客户端
t = tcpclient(address,5000);
data = uint8(1:2);
write(t, data);
pause(1)
read(t,1)

採用された回答

Raghvi
Raghvi 2023 年 3 月 13 日
Hey,
As per my understanding, read(t,1) gives the following error.
Error receiving data from the remote server.
Additional Information: Operation timed out before requested data was received.
read(t,count) reads the number of values specified by count sent to the TCP/IP server t from the client connected to it. You are reading value from the client which is causing the error.
Try using:
read(server,server.NumBytesAvailable)
You can see the documentation and examples provided at
Additionally, you can read from the client when you read data from remote host over TCP/IP. Check this out for more information:
  1 件のコメント
承武
承武 2023 年 3 月 15 日
ok,i see,thank you!

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by