⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcpip_servopen.m

📁 A very small 250-line library (written entirely in MATLAB) that allows multiple MATLAB programs to t
💻 M
字号:
function fid=tcpip_servopen(port)%TCPIP_SERVOPEN opens a blocking TCPIP server socket.%% Call with:%%   fid = tcpip_servopen(port)%% where:%%   port   is the port number of the socket you wish to open.%%   fid      is the retuned handle to the socket, if successful,%            -1 if unsuccessful.%% This function is obsolete.  It has been replaced with TCPIP_SERVSOCKET% and TCPIP_LISTEN.  It is only included for backward compatibility.%% TCPIP_SERVOPEN opens a TCPIP server socket with the requested PORT% number.  This function blocks (waits) until a client socket has% established a connection before returning FID.%% EXAMPLE:%%    disp('Waiting for someone to connect to port 4444...');%    fid = tcpip_servopen(4444);%    if fid = -1%      error('TCP/IP Connection error!');%    end%    disp('Connection! :-)');%    disp('Now sending a message and closing!')%    tcpip_write('Hello!!',string(10)); %string(10) generates newline%    tcpip_close(fid);%% See also:  TCPIP_SERVSPCKET, TCPIP_LISTEN, TCPIP_OPEN%            TCPIP_CLOSE%  fid=-1;  serv_fid = tcpip_servsocket(port);  if serv_fid == -1    return;  end  try,    while fid == -1      fid = tcpip_listen(serv_fid);      pause(1);    end  catch,    tcpip_close(serv_fid);    return;  end  tcpip_close(serv_fid);  return;  

⌨️ 快捷键说明

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