%% Communicate with an Echo Server
% This example shows how to set up an echo server.
% Start the echo server on port 4000 and create a TCPIP object. Connect the TCPIP object to the host.
echotcpip('on',4000)
t = tcpip('localhost',4000);
fopen(t)
%%
% Communicate with the echo server.
% Write to the host and read from the host, then display the read data.
fprintf(t,'echo this string.')
data = fscanf(t);
data
%%
% Dismiss the echo server.
% Stop the echo server and disconnect the TCPIP object from the host.
echotcpip('off')
fclose(t)


%% 
% Copyright 2012 The MathWorks, Inc.