/// <exception cref="System.Exception"></exception>
 public virtual void SetUp()
 {
     _serverSocket = _plainSocketFactory.CreateServerSocket(0);
     _port         = _serverSocket.GetLocalPort();
     _client       = new Socket4Adapter(_plainSocketFactory.CreateSocket("localhost", _port)
                                        );
     _server = new Socket4Adapter(_serverSocket.Accept());
 }
Beispiel #2
0
 /// <exception cref="System.Exception"></exception>
 public virtual void SetUp()
 {
     _serverSocket = _plainSocketFactory.CreateServerSocket(0);
     _port = _serverSocket.GetLocalPort();
     _client = new Socket4Adapter(_plainSocketFactory.CreateSocket("localhost", _port)
         );
     _server = new Socket4Adapter(_serverSocket.Accept());
 }
 private void StartServerSocket()
 {
     try
     {
         _serverSocket = _socketFactory.CreateServerSocket(_port);
         _port         = _serverSocket.GetLocalPort();
     }
     catch (IOException e)
     {
         throw new Db4oIOException(e);
     }
     _serverSocket.SetSoTimeout(_serverConfig.TimeoutServerSocket);
 }
Beispiel #4
0
        public void TestClientCertificateValidation()
        {
            ISocket4Factory sslSocketFactory = new SslSocketFactory(new StandardSocket4Factory(), ServerCertificate());
            IServerSocket4  serverSocket     = sslSocketFactory.CreateServerSocket(0);

            ThreadPool.QueueUserWorkItem(delegate
            {
                serverSocket.Accept();
            });

            SslSocketFactory clientSocketFactory = new SslSocketFactory(new StandardSocket4Factory(), delegate { return(false); });

            Assert.Expect(typeof(AuthenticationException), delegate
            {
                clientSocketFactory.CreateSocket("localhost", serverSocket.GetLocalPort());
            });
        }
Beispiel #5
0
        public void Test()
        {
            ISocket4Factory sslSocketFactory = new SslSocketFactory(new StandardSocket4Factory(), ServerCertificate());
            IServerSocket4  serverSocket     = sslSocketFactory.CreateServerSocket(0);

            PassThroughSocketFactory clientEncryptedContentsSocketFactory = NewPassThroughSocketFactory();
            PassThroughSocketFactory clientPassThroughSocketFactory       = new PassThroughSocketFactory(new SslSocketFactory(clientEncryptedContentsSocketFactory, ValidateServerCertificate));

            Thread clientThread = StartClient(serverSocket.GetLocalPort(), clientPassThroughSocketFactory);

            string msg = ReadString(serverSocket.Accept());

            Assert.AreEqual(Message, msg);
            AssertAreNotEqual(clientEncryptedContentsSocketFactory.LastClient.Written, clientPassThroughSocketFactory.LastClient.Written);

            clientThread.Join();
        }
Beispiel #6
0
        private void AssertTimeoutBehavior(Thread serverTrigger, int serverTimeout, ISocket4Factory clientSocketFactory)
        {
            ISocket4Factory sslSocketFactory = new SslSocketFactory(new StandardSocket4Factory(), ServerCertificate());
            IServerSocket4  serverSocket     = sslSocketFactory.CreateServerSocket(0);

            serverSocket.SetSoTimeout(serverTimeout);

            serverTrigger.IsBackground = true;
            serverTrigger.Start(serverSocket);

            ISocket4 clientSocket = clientSocketFactory.CreateSocket("localhost", serverSocket.GetLocalPort());

            if (!serverTrigger.Join(MinutesToMiliseconds(2)))
            {
                serverTrigger.Abort();
                Assert.Fail("Server thread should have timedout.");
            }
        }
 private void LogListeningOnPort()
 {
     _container.LogMsg(Db4objects.Db4o.Internal.Messages.ServerListeningOnPort, string.Empty
                       + _serverSocket.GetLocalPort());
 }
		private void StartServerSocket()
		{
			try
			{
				_serverSocket = _socketFactory.CreateServerSocket(_port);
				_port = _serverSocket.GetLocalPort();
			}
			catch (IOException e)
			{
				throw new Db4oIOException(e);
			}
			_serverSocket.SetSoTimeout(_serverConfig.TimeoutServerSocket);
		}
Beispiel #9
0
 public virtual int GetLocalPort()
 {
     return(_serverSocket.GetLocalPort());
 }