Implement a windows client
This commit is contained in:
parent
78c59aa3f8
commit
daeb38a861
5 changed files with 70 additions and 2 deletions
19
Tasks/Lab6/.vscode/launch.json
vendored
Normal file
19
Tasks/Lab6/.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch ConsoleApp",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build ConsoleApp",
|
||||||
|
"program": "${workspaceFolder}/bin/Debug/net8.0/ConsoleApp.dll",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"stopAtEntry": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
17
Tasks/Lab6/.vscode/tasks.json
vendored
Normal file
17
Tasks/Lab6/.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build ConsoleApp",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"build",
|
||||||
|
"${workspaceFolder}/ConsoleApp.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
11
Tasks/Lab6/ConsoleApp.csproj
Normal file
11
Tasks/Lab6/ConsoleApp.csproj
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<StartupObject>DT6.SocketClient</StartupObject>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>disable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -22,8 +22,26 @@ namespace DT6 {
|
||||||
public static event Action<string> Received;
|
public static event Action<string> Received;
|
||||||
|
|
||||||
public static void StartClient() {
|
public static void StartClient() {
|
||||||
/* TO BE DONE
|
try
|
||||||
*/
|
{
|
||||||
|
using TcpClient client = new("localhost", 8000);
|
||||||
|
using Stream stream = client.GetStream();
|
||||||
|
using StreamReader reader = new(client.GetStream());
|
||||||
|
using StreamWriter writer = new(client.GetStream());
|
||||||
|
{
|
||||||
|
string line;
|
||||||
|
writer.WriteLine();
|
||||||
|
|
||||||
|
while ((line = reader.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
Received?.Invoke(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "./Tasks/UrlTester"
|
"path": "./Tasks/UrlTester"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./Tasks/Lab6"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue