Transmitting/Sending big packet safely using TcpClient/Socket
Instead of using the ToArray() method of the MemoryStream you could use GetBuffer() instead because this isn't creating a new array. 

Edit based on @Iridium's comment  

But this is only good if you use one of the constructor that creates a not resizable MemoryStream which isn't the case for the default constructor.  

Calling Dispose() on the MemoryStream closes the stream too.  

If you enclose the stream inside inside a using block the disposing of the stream will be handled automatically.

public byte[] ToBytesWithLengthPrefix()
{
    using (var stream = new MemoryStream())
    {
        Serializer.SerializeWithLengthPrefix(stream, this, PrefixStyle.Fixed32);
        return stream.ToArray();
    }
}




I needed to look twice at var data = (byte[])odata; which is a clear sign that you should make the method argument odata easier to distinguish from data, so objectData or dataToSend would be better.  

int buf isn't well named either. One shouldn't use abbreviations to name variables. A much better name would be for instance dataSize or just size to indicate that it is the amount of data being sent.