readline
说明
示例
从远程主机读写 ASCII 数据行
创建一个名为 t
的 TCP/IP 客户端连接,使用端口 4000 连接到 TCP/IP 回显服务器。为此,您必须有在端口 4000 上运行的 echotcpip
服务器。
echotcpip("on",4000) t = tcpclient("localhost",4000)
t = tcpclient with properties: Address: 'localhost' Port: 4000 NumBytesAvailable: 0 Show all properties, functions
检查默认的 ASCII 终止符。
t.Terminator
ans = "LF"
将终止符设置为 "CR"
,并写入一个 ASCII 数据字符串。writeline
函数自动将终止符追加到数据中。
configureTerminator(t,"CR") writeline(t,"hello")
写入自动追加了终止符的另一个 ASCII 数据字符串。
writeline(t,"world")
由于客户端连接到回显服务器,您写入服务器的数据将返回到客户端。读取一个 ASCII 数据字符串。readline
函数返回数据,直到到达终止符。
readline(t)
ans = "hello"
再次读取一个 ASCII 数据字符串,以返回您写入的第二个字符串。
readline(t)
ans = "world"
关闭回显服务器并清除 TCP/IP 客户端连接。
echotcpip("off") clear t
输入参数
版本历史记录
在 R2020b 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)