ferdikurnazdm.Blocks.Socket
1.1.0
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package ferdikurnazdm.Blocks.Socket --version 1.1.0
NuGet\Install-Package ferdikurnazdm.Blocks.Socket -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ferdikurnazdm.Blocks.Socket" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ferdikurnazdm.Blocks.Socket" Version="1.1.0" />
<PackageReference Include="ferdikurnazdm.Blocks.Socket" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ferdikurnazdm.Blocks.Socket --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ferdikurnazdm.Blocks.Socket, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ferdikurnazdm.Blocks.Socket@1.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ferdikurnazdm.Blocks.Socket&version=1.1.0
#tool nuget:?package=ferdikurnazdm.Blocks.Socket&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Socket
/$$$$$$ /$$ /$$
/$$__ $$ | $$ | $$
| $$ \__/ /$$$$$$ /$$$$$$$| $$ /$$ /$$$$$$ /$$$$$$
| $$$$$$ /$$__ $$ /$$_____/| $$ /$$/ /$$__ $$|_ $$_/
\____ $$| $$ \ $$| $$ | $$$$$$/ | $$$$$$$$ | $$
/$$ \ $$| $$ | $$| $$ | $$_ $$ | $$_____/ | $$ /$$
| $$$$$$/| $$$$$$/| $$$$$$$| $$ \ $$| $$$$$$$ | $$$$/
\______/ \______/ \_______/|__/ \__/ \_______/ \___/
This block manage Sockets
Description
This block ensure socket communication and this class configure as client socket and server socket
Getting Started
Dependencies
- .NET 4.7.2 Framework
- .NET Dependency Injection >=9.0.0
Installing
- Install Library with Package Manager script or on Nuget GUI.
Executing program
Usage
Server
Exception exception;
SocketApi<IServerSocket> socketApi = new SocketApi<IServerSocket>.Builder()
.ConfigureForServer(configure => {
configure.IPAddress = IPAddress.Any;
configure.Port = 0;
configure.ReceiveBufferSize = 1024;
configure.TransferBufferSize = 1024;
});
socketApi.Socket.Connected += (clientId) => {
Console.WriteLine($"new connection Id{clientId}");
};
socketApi.Socket.Disconnected += (clientId) => {
Console.WriteLine($"new disconnection Id{clientId}");
};
socketApi.Socket.ReceivedError += (clientId, error) => {
Console.WriteLine($"received error {error} from{clientId}");
};
socketApi.Socket.ReceivedData += (clientId, data) => {
Console.WriteLine($"received data {data.ReceiveBuffer.ToText()} from{clientId}");
Array.Copy(data.ReceiveBuffer, data.SendBuffer, 1024);
if (!socketApi.Socket.TrySend(data, out exception)) {
Console.WriteLine(exception.Message);
}
else {
Console.WriteLine($"sended data {data.SendBuffer.ToText()} ");
}
};
socketApi.Socket.TryInitialize(out exception);
while (true) { Thread.Sleep(6000); }
Client
Exception exception;
SocketApi<IClientSocket> socketApi = new SocketApi<IClientSocket>.Builder()
.ConfigureForClient(configure => {
configure.IPAddress = IPAddress.Parse("127.0.0.1");
configure.Port = 60625;
configure.ReceiveBufferSize = 1024;
configure.TransferBufferSize = 1024;
});
socketApi.Socket.Connected += (clientId) => {
Console.WriteLine($"new connection Id {clientId}");
};
socketApi.Socket.Disconnected += (clientId) => {
Console.WriteLine($"new disconnection Id {clientId}");
};
socketApi.Socket.ReceivedError += (clientId, error) => {
Console.WriteLine($"received error {error} from {clientId}");
};
socketApi.Socket.ReceivedData += (clientId, data) => {
Console.Clear();
Console.WriteLine($"received data {data.ReceiveBuffer.ToText()} from {clientId}");
};
socketApi.Socket.TryInitialize(out exception);
System.Timers.Timer timer = new System.Timers.Timer() {
AutoReset = true,
Interval = 100,
Enabled = true
};
timer.Elapsed += (clientId, elapsed) => {
timer.Stop();
string input = "test";
var server = socketApi.Socket.GetServer();
Array.Copy(input.ToByteArray(), server.SendBuffer, input.ToByteArray().Length);
if (!socketApi.Socket.TrySend(server, out exception)) {
Console.WriteLine(exception.Message);
}
else {
Console.Clear();
Console.WriteLine($"sended data {server.SendBuffer.ToText()} ");
}
timer.Start();
};
while (true) { Thread.Sleep(1000); }
Authors
Ferdi Kurnaz Contact
Version History
- 0.1
- Initial Release
- 0.2
- Auto clear feature
License
This project is licensed under the [MIT] License
Notes:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
- Microsoft.Extensions.DependencyInjection (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|
updated release