System.IO.MemoryStream ms = new System.IO.MemoryStream();
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(ms, struct);
byte[] b=ms.getbuffer();
socket.send(byte);
socket.receive(b);
ms.write(b,0,b.length);
struct s=(struct)bf.Deserialize(ms);