This project is read-only.


This document explains the intent, thinkg and code in the Utilities class

(Image to come)
(Above: Code overview of Utilities class)

The Utilities class is a static class that contains methods that can be utilised in all (or almost all) areas of the networking library.

  • MessageLengthBytes : Constant. The number of bytes to add at the beginning of a message byte array for the bytes specifying the length of the remaining message. This number was set to 64 in the initial release but will probably be increased. Length of the message must be specified so that it can be determined of the whole or mutliple messages are contained within a TCP packet. This stops failure when deserializing due to partial messages being transferred over multiple TCp packets.

  • ToBytes : Static. Converts an object to a byte array using BinaryFormatter. Object type must have serializable attribute.
  • FromBytes : Static. Converts an object from a byte array.
  • FormMessage : Internal. Static. Takes a byte array and adds the length bytes to the start. Length bytes are a 32-bit integer (4 bytes) of the number of bytes in the remaining byte array after LengthBytes have been removed.
  • GetAllMessages : Internal. Static. Extracts all the byte arrays from a single byte array that are seperate messages.

Last edited Dec 17, 2011 at 7:19 PM by EdwardNutting, version 2


No comments yet.