예제 #1
0
파일: TcpAcceptor.cs 프로젝트: keno1213/ice
        internal TcpAcceptor(TcpEndpoint endpoint, ObjectAdapter adapter)
        {
            _adapter = adapter;

            _addr = Network.GetAddressForServerEndpoint(endpoint.Host,
                                                        endpoint.Port,
                                                        endpoint.Communicator.IPVersion,
                                                        endpoint.Communicator.PreferIPv6);

            _socket = Network.CreateServerSocket(false, _addr.AddressFamily, endpoint.Communicator.IPVersion);

            try
            {
                _socket.Bind(_addr);
                _addr = (IPEndPoint)_socket.LocalEndPoint !;
                _socket.Listen(endpoint.Communicator.GetPropertyAsInt("Ice.TCP.Backlog") ?? 511);
            }
            catch (SocketException ex)
            {
                _socket.CloseNoThrow();
                throw new TransportException(ex);
            }

            Endpoint = endpoint.Clone((ushort)_addr.Port);
        }
예제 #2
0
        // TODO: why are we copying all these readonly fields of the endpoint?
        internal TcpConnector(
            TcpEndpoint endpoint,
            Communicator communicator,
            EndPoint addr,
            INetworkProxy?proxy,
            IPAddress?sourceAddr,
            int timeout,
            string connectionId)
        {
            _endpoint     = endpoint;
            _communicator = communicator;
            _addr         = addr;
            _proxy        = proxy;
            _sourceAddr   = sourceAddr;
            _timeout      = timeout;
            _connectionId = connectionId;

            var hash = new System.HashCode();

            hash.Add(_addr);
            if (_sourceAddr != null)
            {
                hash.Add(_sourceAddr);
            }
            hash.Add(_timeout);
            hash.Add(_connectionId);
            _hashCode = hash.ToHashCode();
        }
예제 #3
0
        internal TcpAcceptor(
            TcpEndpoint endpoint,
            Communicator communicator,
            string host,
            ushort port,
            string adapterName)
        {
            _adapterName  = adapterName;
            _endpoint     = endpoint;
            _communicator = communicator;
            _backlog      = communicator.GetPropertyAsInt("Ice.TCP.Backlog") ?? 511;

            try
            {
                int ipVersion = _communicator.IPVersion;
                _addr = Network.GetAddressForServerEndpoint(host, port, ipVersion, _communicator.PreferIPv6);
                _fd   = Network.CreateServerSocket(false, _addr.AddressFamily, ipVersion);
                Network.SetBlock(_fd, false);
                Network.SetTcpBufSize(_fd, _communicator);
            }
            catch (Exception)
            {
                _fd = null;
                throw;
            }
        }
예제 #4
0
파일: TcpAcceptor.cs 프로젝트: wubo2018/ice
        internal TcpAcceptor(TcpEndpoint endpoint, IConnectionManager manager, ObjectAdapter adapter)
        {
            _manager = manager;
            _adapter = adapter;

            _addr = Network.GetAddressForServerEndpoint(endpoint.Host,
                                                        endpoint.Port,
                                                        Network.EnableBoth);

            _socket = Network.CreateServerSocket(endpoint, _addr.AddressFamily);

            try
            {
                _socket.Bind(_addr);
                _addr = (IPEndPoint)_socket.LocalEndPoint !;
                _socket.Listen(endpoint.Communicator.GetPropertyAsInt("Ice.TCP.Backlog") ?? 511);
            }
            catch (SocketException ex)
            {
                _socket.CloseNoThrow();
                throw new TransportException(ex);
            }

            Endpoint = endpoint.Clone((ushort)_addr.Port);
        }
예제 #5
0
파일: TcpConnector.cs 프로젝트: cyyever/ice
        internal TcpConnector(TcpEndpoint endpoint, EndPoint addr, INetworkProxy?proxy)
        {
            _endpoint = endpoint;
            _addr     = addr;
            _proxy    = proxy;

            var hash = new System.HashCode();

            hash.Add(_endpoint.Protocol);
            hash.Add(_endpoint.Transport);
            hash.Add(_addr);
            if (_endpoint.SourceAddress != null)
            {
                hash.Add(_endpoint.SourceAddress);
            }
            _hashCode = hash.ToHashCode();
        }
예제 #6
0
        internal TcpAcceptor(TcpEndpoint endpoint, ObjectAdapter adapter)
        {
            _adapter = adapter;

            _addr = Network.GetAddressForServerEndpoint(endpoint.Host,
                                                        endpoint.Port,
                                                        endpoint.Communicator.IPVersion,
                                                        endpoint.Communicator.PreferIPv6);

            _fd = Network.CreateServerSocket(false, _addr.AddressFamily, endpoint.Communicator.IPVersion);
            Network.SetBlock(_fd, false);
            Network.SetTcpBufSize(_fd, endpoint.Communicator);

            _addr = Network.DoBind(_fd, _addr);
            Network.DoListen(_fd, endpoint.Communicator.GetPropertyAsInt("Ice.TCP.Backlog") ?? 511);

            Endpoint = endpoint.NewPort((ushort)_addr.Port);
        }