title: Buffer filled by nulls. Websockets .net core
body: <p>I built application like live chat in .net core and angular.
  Everything works fine, but, the buffer where received messages are stored, have null bytes after content.</p>
  <p>My buffer have 1024 bytes size.
  But if the message has e.g. 60 bytes, the rest is filled by nulls.</p>
  <p>Should I rewrite received message to new buffer(with appropriate size), and then send further just this new one buffer? (This method I am using now)</p>
  <p>Below is my receive method:</p>
  <pre><code>private async Task Recive(WebSocket socket, Action&lt;WebSocketReceiveResult, byte[]&gt; handle) //original 
  {   
      while(socket.State == WebSocketState.Open)
      {
          var buffer = new byte[1024];
          var result = await socket.ReceiveAsync
          (
              buffer: new ArraySegment&lt;byte&gt;(buffer),
              cancellationToken: CancellationToken.None
          );
  
          handle(result, buffer);
      }
  }
  </code></pre>
  <p>Handle is a function which is called, after app receives data.</p>