在Java中,我们有Socket、BufferedReader和BufferedWriter,那么在C#中对应的是什么呢?
Socket socket;
socket = new Socket(address, port);
reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
在Java中,我们有Socket、BufferedReader和BufferedWriter,那么在C#中对应的是什么呢?
Socket socket;
socket = new Socket(address, port);
reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
using (var client = new TcpClient(address, port))
using (var stream = client.GetStream())
using (var reader = new StreamReader(stream))
{
// TODO: Read from the network stream
}