예제 #1
0
파일: TcpEndpointI.cs 프로젝트: zhaochf/ice
        public override int CompareTo(EndpointI obj)
        {
            if (!(obj is TcpEndpointI))
            {
                return(type() < obj.type() ? -1 : 1);
            }

            TcpEndpointI p = (TcpEndpointI)obj;

            if (this == p)
            {
                return(0);
            }

            if (_timeout < p._timeout)
            {
                return(-1);
            }
            else if (p._timeout < _timeout)
            {
                return(1);
            }

            if (!_compress && p._compress)
            {
                return(-1);
            }
            else if (!p._compress && _compress)
            {
                return(1);
            }

            return(base.CompareTo(p));
        }
예제 #2
0
파일: TcpEndpointI.cs 프로젝트: zhaochf/ice
        public EndpointI create(List <string> args, bool oaEndpoint)
        {
            IPEndpointI endpt = new TcpEndpointI(_instance);

            endpt.initWithOptions(args, oaEndpoint);
            return(endpt);
        }
예제 #3
0
        //
        // Return an acceptor for this endpoint, or null if no acceptors
        // is available. In case an acceptor is created, this operation
        // also returns a new "effective" endpoint, which might differ
        // from this endpoint, for example, if a dynamic port number is
        // assigned.
        //
        public override Acceptor acceptor(ref EndpointI endpoint, string adapterName)
        {
#if SILVERLIGHT
            throw new Ice.FeatureNotSupportedException("server endpoint not supported for `" + ToString() + "'");
#else
            TcpAcceptor p = new TcpAcceptor(_instance, _host, _port);
            endpoint = new TcpEndpointI(_instance, _host, p.effectivePort(), _timeout, connectionId_, _compress);
            return(p);
#endif
        }
예제 #4
0
        //
        // Check whether the endpoint is equivalent to another one.
        //
        public override bool equivalent(EndpointI endpoint)
        {
            if (!(endpoint is TcpEndpointI))
            {
                return(false);
            }

            TcpEndpointI tcpEndpointI = (TcpEndpointI)endpoint;

            return(tcpEndpointI._host.Equals(_host) && tcpEndpointI._port == _port);
        }
예제 #5
0
        //
        // Compare endpoints for sorting purposes
        //
        public override int CompareTo(EndpointI obj)
        {
            if (!(obj is TcpEndpointI))
            {
                return(type() < obj.type() ? -1 : 1);
            }

            TcpEndpointI p = (TcpEndpointI)obj;

            if (this == p)
            {
                return(0);
            }
            else
            {
                int r = base.CompareTo(p);
                if (r != 0)
                {
                    return(r);
                }
            }

            if (_port < p._port)
            {
                return(-1);
            }
            else if (p._port < _port)
            {
                return(1);
            }

            if (_timeout < p._timeout)
            {
                return(-1);
            }
            else if (p._timeout < _timeout)
            {
                return(1);
            }

            if (!_compress && p._compress)
            {
                return(-1);
            }
            else if (!p._compress && _compress)
            {
                return(1);
            }

            return(string.Compare(_host, p._host, StringComparison.Ordinal));
        }
예제 #6
0
        internal TcpAcceptor(TcpEndpointI endpoint, ProtocolInstance instance, string host, int port)
        {
            _endpoint = endpoint;
            _instance = instance;
            _backlog  = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.Backlog", 511);

            try
            {
                int protocol = _instance.protocolSupport();
                _addr = (IPEndPoint)Network.getAddressForServer(host, port, protocol, _instance.preferIPv6());
                _fd   = Network.createServerSocket(false, _addr.AddressFamily, protocol);
                Network.setBlock(_fd, false);
#  if !COMPACT
                Network.setTcpBufSize(_fd, _instance);
#  endif
                if (AssemblyUtil.platform_ != AssemblyUtil.Platform.Windows)
예제 #7
0
파일: TcpAcceptor.cs 프로젝트: skyccn/ice
        internal TcpAcceptor(TcpEndpointI endpoint, ProtocolInstance instance, string host, int port)
        {
            _endpoint = endpoint;
            _instance = instance;
            _backlog  = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.Backlog", 511);

            try
            {
                int protocol = _instance.protocolSupport();
                _addr = (IPEndPoint)Network.getAddressForServer(host, port, protocol, _instance.preferIPv6());
                _fd   = Network.createServerSocket(false, _addr.AddressFamily, protocol);
                Network.setBlock(_fd, false);
                Network.setTcpBufSize(_fd, _instance);
            }
            catch (Exception)
            {
                _fd = null;
                throw;
            }
        }
예제 #8
0
        internal TcpAcceptor(TcpEndpointI endpoint, ProtocolInstance instance, string host, int port)
        {
            _endpoint = endpoint;
            _instance = instance;
            _backlog = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.Backlog", 511);

            try
            {
                int protocol = _instance.protocolSupport();
                _addr = (IPEndPoint)Network.getAddressForServer(host, port, protocol, _instance.preferIPv6());
                _fd = Network.createServerSocket(false, _addr.AddressFamily, protocol);
                Network.setBlock(_fd, false);
            #  if !COMPACT
                Network.setTcpBufSize(_fd, _instance);
            #  endif
                if(AssemblyUtil.platform_ != AssemblyUtil.Platform.Windows)
                {
                    //
                    // Enable SO_REUSEADDR on Unix platforms to allow re-using the
                    // socket even if it's in the TIME_WAIT state. On Windows,
                    // this doesn't appear to be necessary and enabling
                    // SO_REUSEADDR would actually not be a good thing since it
                    // allows a second process to bind to an address even it's
                    // already bound by another process.
                    //
                    // TODO: using SO_EXCLUSIVEADDRUSE on Windows would probably
                    // be better but it's only supported by recent Windows
                    // versions (XP SP2, Windows Server 2003).
                    //
                    Network.setReuseAddress(_fd, true);
                }
            }
            catch(System.Exception)
            {
                _fd = null;
                throw;
            }
        }
예제 #9
0
        internal TcpAcceptor(TcpEndpointI endpoint, ProtocolInstance instance, string host, int port)
        {
            _endpoint = endpoint;
            _instance = instance;
            _backlog  = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.Backlog", 511);

            try
            {
                int protocol = _instance.protocolSupport();
                _addr = (IPEndPoint)Network.getAddressForServer(host, port, protocol, _instance.preferIPv6());
                _fd   = Network.createServerSocket(false, _addr.AddressFamily, protocol);
                Network.setBlock(_fd, false);
                Network.setTcpBufSize(_fd, _instance);
                if (AssemblyUtil.platform_ != AssemblyUtil.Platform.Windows)
                {
                    //
                    // Enable SO_REUSEADDR on Unix platforms to allow re-using the
                    // socket even if it's in the TIME_WAIT state. On Windows,
                    // this doesn't appear to be necessary and enabling
                    // SO_REUSEADDR would actually not be a good thing since it
                    // allows a second process to bind to an address even it's
                    // already bound by another process.
                    //
                    // TODO: using SO_EXCLUSIVEADDRUSE on Windows would probably
                    // be better but it's only supported by recent Windows
                    // versions (XP SP2, Windows Server 2003).
                    //
                    Network.setReuseAddress(_fd, true);
                }
            }
            catch (System.Exception)
            {
                _fd = null;
                throw;
            }
        }
예제 #10
0
        //
        // Return an acceptor for this endpoint, or null if no acceptors
        // is available. In case an acceptor is created, this operation
        // also returns a new "effective" endpoint, which might differ
        // from this endpoint, for example, if a dynamic port number is
        // assigned.
        //
        public override Acceptor acceptor(ref EndpointI endpoint, string adapterName)
        {
#if SILVERLIGHT
            throw new Ice.FeatureNotSupportedException("server endpoint not supported for `" + ToString() + "'");
#else
            TcpAcceptor p = new TcpAcceptor(_instance, _host, _port);
            endpoint = new TcpEndpointI(_instance, _host, p.effectivePort(), _timeout, connectionId_, _compress);
            return p;
#endif
        }
예제 #11
0
 public EndpointI create(List<string> args, bool oaEndpoint)
 {
     IPEndpointI endpt = new TcpEndpointI(_instance);
     endpt.initWithOptions(args, oaEndpoint);
     return endpt;
 }
예제 #12
0
 public virtual EndpointI listen()
 {
     try
     {
         _addr = Network.doBind(_fd, _addr);
         Network.doListen(_fd, _backlog);
     }
     catch(SystemException)
     {
         _fd = null;
         throw;
     }
     _endpoint = _endpoint.endpoint(this);
     return _endpoint;
 }
예제 #13
0
 //
 // Return an acceptor for this endpoint, or null if no acceptors
 // is available. In case an acceptor is created, this operation
 // also returns a new "effective" endpoint, which might differ
 // from this endpoint, for example, if a dynamic port number is
 // assigned.
 //
 public override Acceptor acceptor(ref EndpointI endpoint, string adapterName)
 {
     TcpAcceptor p = new TcpAcceptor(_instance, _host, _port);
     endpoint = new TcpEndpointI(_instance, _host, p.effectivePort(), _timeout, _connectionId, _compress);
     return p;
 }