Fixes not getting \n on starting packet which would then have client send it on next packet, which then was wrong size.

This commit is contained in:
hondacrx
2020-08-20 23:28:23 -04:00
parent 165ae9e4f0
commit e049db795f
6 changed files with 281 additions and 192 deletions
+40
View File
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Framework.IO
{
public class SocketBuffer
{
byte[] _storage;
int _wpos;
public SocketBuffer(int initialSize = 0)
{
_storage = new byte[initialSize];
}
public void Resize(int bytes)
{
_storage = new byte[bytes];
}
public byte[] GetData()
{
return _storage;
}
public void Write(byte[] data, int index, int size)
{
Buffer.BlockCopy(data, index, _storage, _wpos, size);
_wpos += size;
}
public int GetRemainingSpace() { return _storage.Length - _wpos; }
public void Reset()
{
_wpos = 0;
}
}
}