-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Simple FTP #5
Conversation
@@ -0,0 +1,142 @@ | |||
namespace Client; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Надо бы линтер настроить, очень ему Ваш код не нравится
SimpleFTP/Client/Client.cs
Outdated
/// <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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это инициирует синхронное подключение. Тут надо было использовать конструктор без параметров и потом ConnectToAsync
SimpleFTP/Client/Client.cs
Outdated
|
||
var response = await _reader.ReadLineAsync(); | ||
|
||
return response is null or "-1" ? (-1, new List<(string, bool)>()) : ParseResponse(response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Длину списка можно было не возвращать, он её сам знает
SimpleFTP/Client/Program.cs
Outdated
@@ -0,0 +1,9 @@ | |||
using var client = new Client.Client(8888, "localhost"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это стоило принимать как параметры командной строки
SimpleFTP/FTPTests/FTPTests.cs
Outdated
[OneTimeSetUp] | ||
public void OneTimeSetUp() | ||
{ | ||
Task.Run(async () => await _server.RunAsync()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Надо иметь возможность дождаться корректной остановки
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Неплохо бы проверить ещё одновременное подключение несколькими клиентами
SimpleFTP/Server/Program.cs
Outdated
@@ -0,0 +1,2 @@ | |||
using var server = new Server.Server(8888); | |||
await server.RunAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Надо реализовать какой-то механизм остановки, типа по нажатию перевода строки
SimpleFTP/Server/Server.cs
Outdated
using var socket = await _listener.AcceptSocketAsync(token); | ||
await using var stream = new NetworkStream(socket); | ||
|
||
await ProcessQuery(stream); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Так получается, что пока сервер обслуживает одного клиента, он не может обслуживать следующих. Нехорошо. Надо больше параллелизма.
No description provided.