TCP Send and Recieve

This commit is contained in:
Timerix22 2023-10-13 12:24:08 +06:00
parent 86161b5c95
commit 34ae7c2e2b
2 changed files with 16 additions and 2 deletions

View File

@ -29,7 +29,7 @@ public class TCPSocketClient : IDisposable
public void Dispose() => Stop();
public void Send(byte[] buffer)
public void Send(ref byte[] buffer)
{
if (_mainSocket is null)
throw new NullReferenceException("TCP socket is null! You have to call Connect() befure calling Send()");
@ -40,6 +40,6 @@ public class TCPSocketClient : IDisposable
{
if (_mainSocket is null)
throw new NullReferenceException("TCP socket is null! You have to call Connect() befure calling Recieve()");
_mainSocket.Receive(buffer);
return _mainSocket.Receive(buffer);
}
}

View File

@ -98,4 +98,18 @@ public class TCPSocketServer : IDisposable
}
public void Dispose() => Stop();
public void Send(ref byte[] buffer)
{
if (_mainSocket is null)
throw new NullReferenceException("TCP socket is null! You have to call Connect() befure calling Send()");
_mainSocket.Send(buffer);
}
public int Recieve(ref byte[] buffer)
{
if (_mainSocket is null)
throw new NullReferenceException("TCP socket is null! You have to call Connect() befure calling Recieve()");
return _mainSocket.Receive(buffer);
}
}