Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple FTP #5

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Simple FTP #5

wants to merge 14 commits into from

Conversation

artemiipatov
Copy link
Owner

No description provided.

@@ -0,0 +1,142 @@
namespace Client;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо бы линтер настроить, очень ему Ваш код не нравится

/// <param name="host">The DNS name of the remote host to which you intend to connect.</param>
public Client(int port, string host)
{
_client = new TcpClient(host, port);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это инициирует синхронное подключение. Тут надо было использовать конструктор без параметров и потом ConnectToAsync


var response = await _reader.ReadLineAsync();

return response is null or "-1" ? (-1, new List<(string, bool)>()) : ParseResponse(response);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Длину списка можно было не возвращать, он её сам знает

@@ -0,0 +1,9 @@
using var client = new Client.Client(8888, "localhost");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это стоило принимать как параметры командной строки

[OneTimeSetUp]
public void OneTimeSetUp()
{
Task.Run(async () => await _server.RunAsync());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо иметь возможность дождаться корректной остановки

}
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Неплохо бы проверить ещё одновременное подключение несколькими клиентами

@@ -0,0 +1,2 @@
using var server = new Server.Server(8888);
await server.RunAsync();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо реализовать какой-то механизм остановки, типа по нажатию перевода строки

using var socket = await _listener.AcceptSocketAsync(token);
await using var stream = new NetworkStream(socket);

await ProcessQuery(stream);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так получается, что пока сервер обслуживает одного клиента, он не может обслуживать следующих. Нехорошо. Надо больше параллелизма.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants