How to Transfer Image file from server to client using TCP IP ?

6 ビュー (過去 30 日間)
Selva Karna
Selva Karna 2018 年 3 月 31 日
回答済み: Zdenek Kubin 2018 年 6 月 8 日
How to Transfer Image file from server to client using TCP IP ?

採用された回答

Zdenek Kubin
Zdenek Kubin 2018 年 6 月 8 日
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 件)

カテゴリ

Help Center および File ExchangeWeb Services についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by