Supercell.GUT/Supercell.GUT.Server/Network/Tcp/TcpSocketEntity.cs
BreadDEV ad23f95319 [v0.0.1] very early state server
only basic messages, wip.
2024-03-04 20:19:32 +07:00

30 lines
No EOL
732 B
C#

using System.Net;
using System.Net.Sockets;
namespace Supercell.GUT.Server.Network.Tcp;
internal class TcpSocketEntity : IProtocolEntity
{
private readonly Socket _socket;
public TcpSocketEntity(Socket socket)
{
_socket = socket;
}
public EndPoint RemoteEndPoint => _socket.RemoteEndPoint!;
public ValueTask<int> ReceiveAsync(Memory<byte> buffer, CancellationToken cancellationToken)
{
return _socket.ReceiveAsync(buffer, cancellationToken);
}
public ValueTask<int> SendAsync(Memory<byte> buffer, CancellationToken cancellationToken)
{
return _socket.SendAsync(buffer, cancellationToken);
}
public void Dispose()
{
_socket.Close();
}
}