Skip to content

Commit a462099

Browse files
committed
Fixed bug in SimplSocket regarding message length calculation
1 parent 9f2552c commit a462099

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

SimplSockets/SimplSocket.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static ISimplSocketClient CreateClient(Func<Socket> socketFunc, EventHand
7676
/// <param name="messageBufferSize">The message buffer size to use for send/receive.</param>
7777
/// <param name="maximumConnections">The maximum connections to allow to use the socket simultaneously.</param>
7878
/// <param name="useNagleAlgorithm">Whether or not to use the Nagle algorithm.</param>
79-
public static ISimplSocketServer CreateServer(Func<Socket> socketFunc, EventHandler<SocketErrorArgs> errorHandler, EventHandler<MessageReceivedArgs> messageHandler,
79+
public static ISimplSocketServer CreateServer(Func<Socket> socketFunc, EventHandler<SocketErrorArgs> errorHandler, EventHandler<MessageReceivedArgs> messageHandler,
8080
int messageBufferSize, int maximumConnections, bool useNagleAlgorithm)
8181
{
8282
// Sanitize
@@ -872,7 +872,7 @@ private static void SetControlBytes(byte[] buffer, int threadId)
872872

873873
private static void ExtractControlBytes(byte[] buffer, int offset, out int messageLength, out int threadId)
874874
{
875-
messageLength = (buffer[offset + 3] << 24) | (buffer[offset + 2] << 16) | (buffer[offset + 1] << 8) | buffer[offset + 0] - _controlBytesPlaceholder.Length;
875+
messageLength = ((buffer[offset + 3] << 24) | (buffer[offset + 2] << 16) | (buffer[offset + 1] << 8) | buffer[offset + 0]) - _controlBytesPlaceholder.Length;
876876
threadId = (buffer[offset + 7] << 24) | (buffer[offset + 6] << 16) | (buffer[offset + 5] << 8) | buffer[offset + 4];
877877
}
878878

0 commit comments

Comments
 (0)