private static void _setupNewSocketServer(RelayNode relayNode, string instanceName, int portNumber, bool useAsyncHandler, ConnectionWhitelist connectionWhitelist, bool whitelistOnly) 
		{
			//all public method should lock(_syncRoot) so we should be ok
			SocketServer socketServer = new SocketServer(instanceName, portNumber);

			IMessageHandler messageHandler;
			if (useAsyncHandler)
			{
				messageHandler = new SocketServerAsyncMessageHandler(relayNode, relayNode);
			}
			else
			{
				messageHandler = new SocketServerRelayMessageHandler(relayNode, relayNode);
			}

			socketServer.MessageHandler = messageHandler;
			socketServer.AcceptingConnectionsDelegate = relayNode.AcceptNewConnection;
			socketServer.WhitelistOnly = whitelistOnly;
			socketServer.Start(connectionWhitelist);

			_socketServer = socketServer;
			if (_cachedWhiteListValue != null)
			{
				_socketServer.WhitelistOnly = _cachedWhiteListValue.Value;
				_cachedWhiteListValue = null;
			}
    	}
        /// <summary>
        /// Binds the server to a port and starts the server to accept new connections.
        /// </summary>
        /// <param name="instanceName"></param>
        /// <param name="portNumber"></param>
        /// <param name="relayNode">The node to handle new message requests.</param>
		/// <param name="useAsyncHandler">A value indicating if out messages should be asynchronous.</param>
		/// <param name="connectionWhitelist">A delegate that tells if a given
		/// remote endpoint is allowable to connect.</param>
		/// <param name="whitelistOnly">Whether to only allow whitelisted connections.</param>
		public static void Initialize(string instanceName, int portNumber, RelayNode relayNode,
			bool useAsyncHandler, ConnectionWhitelist connectionWhitelist,
			bool whitelistOnly)
        {
			lock (_syncRoot)
			{
        		_myRelayNode = relayNode;
				_connectionWhitelist = connectionWhitelist;
				_setupNewSocketServer(relayNode, instanceName, portNumber,
					useAsyncHandler, _connectionWhitelist, whitelistOnly);
			}
        }