tcpip_sendfile.m

来自「A very small 250-line library (written e」· M 代码 · 共 35 行

M
35
字号
function ret=tcpip_sendfile(ip_fid,name)  %%  ret = tcpip_sendfile(ip_fid,name)%%  ip_fid     Number for tcpip channel.%  name    Name of file to send%  ret     Return value%% Send a file over network with tcpip.% Using a own protocol. se also tcpip_getfile%    NL=char(10);  %Define newline character    fh=dir(name);    fid=fopen(name,'rb');    if fid==-1,    ret=-1;    return;  end    dump=tcpip_write(ip_fid,NL,'==BINFILE==',NL,fh.name,NL,num2str(fh.bytes),NL,'DATA:');    buff='';  while feof(fid)==0,    buff=[buff,char(fread(fid,100000))];    buff=tcpip_write(ip_fid,buff);  end  dump=tcpip_write(ip_fid,'==END==',NL);  fclose(fid);  return;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?