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 명령 창에 입력하십시오. 웹 브라우저는 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)