Supercell.GUT/Supercell.GUT.Server/Network/Tcp/TcpSocketEntity.cs

30 lines
732 B
C#
Raw Normal View History

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();
}
}