Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26ecb5f
commit b6fbb8a
Showing
5 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BeetleX" Version="1.4.8.3" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using BeetleX; | ||
using BeetleX.Clients; | ||
using System; | ||
using System.Net; | ||
|
||
namespace Client | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
AsyncTcpClient client = SocketFactory.CreateClient<AsyncTcpClient>("127.0.0.1", 9090); | ||
client.DataReceive = (o, e) => | ||
{ | ||
var pipestream = e.Stream.ToPipeStream(); | ||
if (pipestream.TryReadLine(out string line)) | ||
{ | ||
Console.WriteLine(line); | ||
} | ||
}; | ||
while (true) | ||
{ | ||
Console.Write("Enter Name:"); | ||
BytesHandler line = Console.ReadLine() + "\r\n"; | ||
client.Send(line); | ||
if(!client.IsConnected) | ||
{ | ||
Console.WriteLine(client.LastError.Message); | ||
} | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using BeetleX; | ||
using BeetleX.EventArgs; | ||
using System; | ||
|
||
namespace Server | ||
{ | ||
class Program : ServerHandlerBase | ||
{ | ||
private static IServer server; | ||
public static void Main(string[] args) | ||
{ | ||
server = SocketFactory.CreateTcpServer<Program>(); | ||
//server.Options.DefaultListen.Port =9090; | ||
//server.Options.DefaultListen.Host = "127.0.0.1"; | ||
server.Open(); | ||
Console.Read(); | ||
} | ||
public override void SessionReceive(IServer server, SessionReceiveEventArgs e) | ||
{ | ||
var pipeStream = e.Stream.ToPipeStream(); | ||
if (pipeStream.TryReadLine(out string name)) | ||
{ | ||
Console.WriteLine(name); | ||
e.Session.Stream.ToPipeStream().WriteLine("hello " + name); | ||
e.Session.Stream.Flush(); | ||
} | ||
base.SessionReceive(server, e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BeetleX" Version="1.4.8.3" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28307.705 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "Server\Server.csproj", "{01636360-991A-43DE-8C32-78C00D5C7406}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client\Client.csproj", "{7C8A6B33-57CF-4FA0-B855-E6411C378194}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{01636360-991A-43DE-8C32-78C00D5C7406}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{01636360-991A-43DE-8C32-78C00D5C7406}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{01636360-991A-43DE-8C32-78C00D5C7406}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{01636360-991A-43DE-8C32-78C00D5C7406}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{7C8A6B33-57CF-4FA0-B855-E6411C378194}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{7C8A6B33-57CF-4FA0-B855-E6411C378194}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{7C8A6B33-57CF-4FA0-B855-E6411C378194}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{7C8A6B33-57CF-4FA0-B855-E6411C378194}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {A2A9DF2D-E003-4BEB-A5F3-B3B46279390B} | ||
EndGlobalSection | ||
EndGlobal |