This commit is contained in:
user
2026-01-28 13:56:53 +04:00
parent d311a1796e
commit 5f6c3d1c0c
5 changed files with 126 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Client_App</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

36
Client App/Program.cs Normal file
View File

@@ -0,0 +1,36 @@
using System;
using System.Net.Sockets;
using System.Text;
class Client
{
static void Main()
{
TcpClient client = new TcpClient();
try
{
client.Connect("127.0.0.1", 8888);
NetworkStream stream = client.GetStream();
Console.Write("Текст: ");
string text = Console.ReadLine();
byte[] data = Encoding.UTF8.GetBytes(text);
stream.Write(data, 0, data.Length);
data = new byte[1024];
int bytes = stream.Read(data, 0, data.Length);
string response = Encoding.UTF8.GetString(data, 0, bytes);
Console.WriteLine($"Ответ: {response}");
stream.Close();
client.Close();
}
catch (Exception e)
{
Console.WriteLine($"Ошибка: {e.Message}");
}
}
}