mirror of
https://github.com/thebreaddev/Supercell.GUT.git
synced 2024-11-14 01:14:37 +00:00
30 lines
732 B
C#
30 lines
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();
|
|||
|
}
|
|||
|
}
|