From 34ae7c2e2b1e5a4d0e0817a48422b4e15e1c6980 Mon Sep 17 00:00:00 2001 From: Timerix22 Date: Fri, 13 Oct 2023 12:24:08 +0600 Subject: [PATCH] TCP Send and Recieve --- DTLib.Network/TCPSocketClient.cs | 4 ++-- DTLib.Network/TCPSocketServer.cs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/DTLib.Network/TCPSocketClient.cs b/DTLib.Network/TCPSocketClient.cs index 511ede9..941832b 100644 --- a/DTLib.Network/TCPSocketClient.cs +++ b/DTLib.Network/TCPSocketClient.cs @@ -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); } } \ No newline at end of file diff --git a/DTLib.Network/TCPSocketServer.cs b/DTLib.Network/TCPSocketServer.cs index b09852a..06e63a5 100644 --- a/DTLib.Network/TCPSocketServer.cs +++ b/DTLib.Network/TCPSocketServer.cs @@ -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); + } } \ No newline at end of file