How to Transfer Image file from server to client using TCP IP ?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Selva Karna
le 31 Mar 2018
Réponse apportée : Zdenek Kubin
le 8 Juin 2018
How to Transfer Image file from server to client using TCP IP ?
0 commentaires
Réponse acceptée
Zdenek Kubin
le 8 Juin 2018
Hi, some time ago I download from this exchange this code:
Server:
data =imread('ngc6543a.jpg');
data=im2double(data);
s = whos('data');
s.size;
s.bytes;
tcpipServer = tcpip('...', 30000, 'NetworkRole', 'Server');
set(tcpipServer, 'OutputBufferSize', s.bytes);
fopen(tcpipServer);
fwrite(tcpipServer, data(:), 'double');
fclose(tcpipServer);
Client:
tcpipClient = tcpip('...',30000);
set(tcpipClient,'InputBufferSize',300000);
set(tcpipClient,'Timeout',5); %Waiting time in seconds to complete read and write operations
fopen(tcpipClient);
get(tcpipClient, 'BytesAvailable');
tcpipClient.BytesAvailable
DataReceived =[];
pause(0.1);
while (get(tcpipClient, 'BytesAvailable') > 0)
tcpipClient.BytesAvailable
rawData = fread(tcpipClient,300000/8,'double');
DataReceived = [DataReceived; rawData];
pause(0.1)
end
fclose(tcpipClient);
delete(tcpipClient);
clear tcpipClient
% ploting
reshapedData = reshape(DataReceived,650,600,3);
imshow(reshapedData)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Web Services dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!