2
여기에 밀도가 있습니까? StreamReader.ReadLine 그 상태 :StreamReader.ReadLine 및 CR
라인은 라인 피드 ("\ n")를, 캐리지 리턴 다음 문자 시퀀스로서 정의된다 ("\ r에") 또는 캐리지 리턴이 즉시 개행 이어 ("\ r \ n")
따라서 예상대로 작동하지 않는 이유는 무엇입니까?
' Server
Dim tcpL as New TcpListener(IPAddress.Any, 5000)
tcpL.Start(1)
Using tcpC as TcpClient = tcpL.AcceptTcpClient(), _
s as NetworkStream = tcpC.GetStream(), _
sr as New StreamReader(s, System.Text.Encoding.ASCII, True)
Dim message As String = sr.ReadLine()
Console.WriteLine(message)
End Using
Console.ReadLine()
' Client
Using tcpC as New TcpClient()
tcpC.Connect(IPAddress.Loopback, 5000)
Using s as NetworkStream = tcpC.GetStream(), _
sw as New StreamWriter(s, System.Text.Encoding.ASCII)
sw.AutoFlush = True
sw.Write("Hello there!")
sw.Write(vbCR) ' Note the CR terminator
Console.ReadLine()
End Using
End Using
서버가 분리 될 때까지 ReadLine
에서 반환되지 않습니다 - CR 전송하더라도. vbLF
또는 vbCRLF
으로 변경하면 예상대로 반환됩니다.
문서가 잘못되었거나 여기에 뭔가가 있습니다 ....?
Ahh - 완벽한 의미를 가지며 완벽하게 쓸모 없게 만듭니다. 메시지가 CR로 끝나기 때문에 더 이상 보낼 데이터가 없습니다. –
최소한이 특질에 대한 문서가 더 나올 것입니다. – Fantius