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

조회 수: 5 (최근 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 CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by