2023-08-29 19:36:58 +02:00
|
|
|
|
using Microsoft.AspNetCore.Authentication.OAuth.Claims;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Net.Sockets;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Serilog;
|
2023-09-02 15:47:15 +02:00
|
|
|
|
using Microsoft.AspNetCore.Http;
|
2023-08-29 19:36:58 +02:00
|
|
|
|
|
|
|
|
|
namespace service
|
|
|
|
|
{
|
|
|
|
|
public class Client
|
|
|
|
|
{
|
2023-09-02 15:47:15 +02:00
|
|
|
|
private IPEndPoint _ipEndPoint;
|
|
|
|
|
private TcpClient _tcpClient;
|
|
|
|
|
private byte[] _buffer;
|
|
|
|
|
private int _bufferSize;
|
2023-08-29 19:36:58 +02:00
|
|
|
|
|
2023-09-02 15:47:15 +02:00
|
|
|
|
public Client(byte[] buffer, int bufferSize)
|
|
|
|
|
{
|
|
|
|
|
_ipEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8888);
|
|
|
|
|
_tcpClient = new TcpClient();
|
|
|
|
|
_buffer = buffer;
|
|
|
|
|
_bufferSize = bufferSize;
|
2023-08-29 19:36:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-02 15:47:15 +02:00
|
|
|
|
public void SendMessageToServer()
|
2023-08-29 19:36:58 +02:00
|
|
|
|
{
|
2023-09-02 15:47:15 +02:00
|
|
|
|
_tcpClient.Connect(_ipEndPoint);
|
|
|
|
|
NetworkStream stream = _tcpClient.GetStream();
|
|
|
|
|
stream.BeginWrite(_buffer, 0, _bufferSize, null, null);
|
2023-08-29 19:36:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|