Files
tcpipSocket/TAP/Client/Client.cs

24 lines
562 B
C#
Raw Permalink Normal View History

2023-02-07 14:44:58 +09:00
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace Client
{
internal class Client
{
static async Task Main(string[] args)
{
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 20000);
await socket.ConnectAsync(endPoint);
while (true)
{
string str = Console.ReadLine() ?? string.Empty;
byte[] buffer = Encoding.UTF8.GetBytes(str);
await socket.SendAsync(buffer, SocketFlags.None);
}
}
}
}