Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        public EndpointI create(List <string> args, bool oaEndpoint)
        {
            IPEndpointI endpt = new TcpEndpointI(_instance);

            endpt.initWithOptions(args, oaEndpoint);
            return(endpt);
        }
Ejemplo n.º 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
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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)
Ejemplo n.º 7
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);
            }
            catch (Exception)
            {
                _fd = null;
                throw;
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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
        }
Ejemplo n.º 11
0
 public EndpointI create(List<string> args, bool oaEndpoint)
 {
     IPEndpointI endpt = new TcpEndpointI(_instance);
     endpt.initWithOptions(args, oaEndpoint);
     return endpt;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }