update
This commit is contained in:
11
Client App/Client App.csproj
Normal file
11
Client App/Client App.csproj
Normal 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
36
Client App/Program.cs
Normal 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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user