async socket telnet

This commit is contained in:
2023-05-12 17:55:51 +09:00
parent 59f0977eaf
commit 16d0ca5d8a
8 changed files with 310 additions and 24 deletions

View File

@@ -21,7 +21,7 @@ namespace ConsoleApp.TelnetSamples
_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_socket.ReceiveTimeout = 1000;
IPAddress ipAddress = IPAddress.Parse(ip);
IPAddress ipAddress = Dns.GetHostAddresses(ip)[0];
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, port);
_socket.Connect(ipEndPoint);
@@ -33,7 +33,7 @@ namespace ConsoleApp.TelnetSamples
}
}
public string Read()
private string Read()
{
StringBuilder sb = new StringBuilder();
byte[] readBuffer = new byte[1024];
@@ -48,8 +48,6 @@ namespace ConsoleApp.TelnetSamples
if (data.EndsWith("\r\n>"))
break;
Thread.Sleep(50);
}
// 에코 삭제