how to send data through Echo TCPIP Server in MATLAB

hi,my name is Deepu, i want to send stream of data through Echo TCPIP Server, is it possible?How?
NOTE: i'm using 2018a verson MATLAB
Thankyou.........

Réponses (1)

yanqi liu
yanqi liu le 5 Jan 2022

0 votes

10 commentaires

configureTerminator(t,"LF");
Hello in the above code, "LF" what it means?
Thank you
configureCallback(t,"byte",10,@readDataFcn);
Hi, the above code where is to put in server side or in client side??
Thankyou
yes,sir
ts = tcpserver("127.0.0.1",4000)
ts =
TCPServer with properties: ServerAddress: "127.0.0.1" ServerPort: 4000 Connected: 0 ClientAddress: "" ClientPort: [] NumBytesAvailable: 0 Show all properties, functions
tc = tcpclient("127.0.0.1",4000)
tc =
tcpclient with properties: Address: '127.0.0.1' Port: 4000 NumBytesAvailable: 0 Show all properties, functions
Deepu S S
Deepu S S le 5 Jan 2022
Modifié(e) : Deepu S S le 5 Jan 2022
How can i send and recieve stream of data through tcpip in matlab??
Note: The server and client in same computer but different Matlab scripts.Is it possible to transmitte stream of data with in acomputer,like the system act as server and client.When i run server script it will send stream of data to the client,the client will recieve the stream of data from server.
Which MATLAB libraries i want to use ?
is there any existing MATLAB examples like this available in MathWorks?
yes,sir,may be check
run in one MATLAB env
% server
close all;clear all;clc;
t_server=tcpip('0.0.0.0',4000,'NetworkRole','server');
fopen(t_server);
try_times=100;
for i=1:try_times
pause(0.02);
try
data_recv=fread(t_server,t_server.BytesAvailable);
fprintf('\n%s\n',char(data_recv));
catch
t_server.ValuesReceived;
end
end
run in another MATLAB env
% client
close all;clear all;clc;
t_client=tcpip('localhost',4000,'NetworkRole','client');
fopen(t_client);
% data_send=sin(1:64);
txt_send='HELLO, Deepu S S';
pause(1);
% fwrite(t_client,data_send);
fprintf(t_client,txt_send);
we run the first、the second,and then,the first MATLAB env can get
this is string,may be add some encode、decode method,use it as communication demo
Thank you now its work. And like this can i send one file from one computer to another is it possible??????
yes,sir,what is the file type?is it “.txt” or anything?
.ASCII file
yes,sir,may be use base64 encode to string and decode to file
how ?

Connectez-vous pour commenter.

Commenté :

le 11 Jan 2022

Community Treasure Hunt

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

Start Hunting!

Translated by