/// <summary>
        /// Called by the OS when the socket connects to the server.
        /// </summary>
        public static void ConnectedToServer(IAsyncResult stateAsArObject)
        {
            SocketState state = (SocketState)stateAsArObject;

            state.InvokeNetworkAction(state);
        }
 /// <summary>
 /// Takes in a SocketState, s, and calls the NetworkAction method stored
 /// by s.
 /// </summary>
 public void InvokeNetworkAction(SocketState s)
 {
     s.action(s);
 }