Пример #1
0
        public EndpointI create(List <string> args, bool oaEndpoint)
        {
            IPEndpointI endpt = new UdpEndpointI(_instance);

            endpt.initWithOptions(args, oaEndpoint);
            return(endpt);
        }
Пример #2
0
        //
        // Return a server side transceiver for this endpoint, or null if a
        // transceiver can only be created by an acceptor. In case a
        // transceiver 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 Transceiver transceiver(ref EndpointI endpoint)
        {
            UdpTransceiver p = new UdpTransceiver(instance_, _host, _port, _mcastInterface, _connect);

            endpoint = new UdpEndpointI(instance_, _host, p.effectivePort(), _mcastInterface, _mcastTtl,
                                        _connect, connectionId_, _compress);
            return(p);
        }
Пример #3
0
        //
        // Check whether the endpoint is equivalent to another one.
        //
        public override bool equivalent(EndpointI endpoint)
        {
            if (!(endpoint is UdpEndpointI))
            {
                return(false);
            }

            UdpEndpointI udpEndpointI = (UdpEndpointI)endpoint;

            return(udpEndpointI._host.Equals(_host) && udpEndpointI._port == _port);
        }
Пример #4
0
        //
        // Compare endpoints for sorting purposes
        //
        public override int CompareTo(EndpointI obj)
        {
            if (!(obj is UdpEndpointI))
            {
                return(type() < obj.type() ? -1 : 1);
            }

            UdpEndpointI p = (UdpEndpointI)obj;

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

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

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

            int rc = string.Compare(_mcastInterface, p._mcastInterface, StringComparison.Ordinal);

            if (rc != 0)
            {
                return(rc);
            }

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

            return(base.CompareTo(p));
        }
Пример #5
0
        //
        // Only for use by UdpEndpoint.
        //
        internal UdpTransceiver(UdpEndpointI endpoint, ProtocolInstance instance, string host, int port,
                                string mcastInterface, bool connect)
        {
            _endpoint       = endpoint;
            _instance       = instance;
            _state          = connect ? StateNeedConnect : StateNotConnected;
            _mcastInterface = mcastInterface;
            _incoming       = true;
            _port           = port;

            try
            {
                _addr = Network.getAddressForServer(host, port, instance.protocolSupport(), instance.preferIPv6());

                _readEventArgs = new SocketAsyncEventArgs();
                _readEventArgs.RemoteEndPoint = _addr;
                _readEventArgs.Completed     += new EventHandler <SocketAsyncEventArgs>(ioCompleted);

                _writeEventArgs = new SocketAsyncEventArgs();
                _writeEventArgs.RemoteEndPoint = _addr;
                _writeEventArgs.Completed     += new EventHandler <SocketAsyncEventArgs>(ioCompleted);

                _fd = Network.createServerSocket(true, _addr.AddressFamily, instance.protocolSupport());
                setBufSize(-1, -1);
                Network.setBlock(_fd, false);
            }
            catch (Ice.LocalException)
            {
                if (_readEventArgs != null)
                {
                    _readEventArgs.Dispose();
                }
                if (_writeEventArgs != null)
                {
                    _writeEventArgs.Dispose();
                }
                _fd = null;
                throw;
            }
        }
Пример #6
0
 public InfoI(UdpEndpointI e)
 {
     _endpoint = e;
 }
Пример #7
0
 public InfoI(UdpEndpointI e)
 {
     _endpoint = e;
 }
Пример #8
0
 public EndpointI create(List<string> args, bool oaEndpoint)
 {
     IPEndpointI endpt = new UdpEndpointI(_instance);
     endpt.initWithOptions(args, oaEndpoint);
     return endpt;
 }
Пример #9
0
 public EndpointI bind()
 {
     if(Network.isMulticast((IPEndPoint)_addr))
     {
         Network.setReuseAddress(_fd, true);
         _mcastAddr = (IPEndPoint)_addr;
         if(AssemblyUtil.platform_ == AssemblyUtil.Platform.Windows)
         {
             //
             // Windows does not allow binding to the mcast address itself
             // so we bind to INADDR_ANY (0.0.0.0) instead. As a result,
             // bi-directional connection won't work because the source
             // address won't the multicast address and the client will
             // therefore reject the datagram.
             //
             if(_addr.AddressFamily == AddressFamily.InterNetwork)
             {
                 _addr = new IPEndPoint(IPAddress.Any, _port);
             }
             else
             {
                 _addr = new IPEndPoint(IPAddress.IPv6Any, _port);
             }
         }
         _addr = Network.doBind(_fd, _addr);
         if(_port == 0)
         {
             _mcastAddr.Port = ((IPEndPoint)_addr).Port;
         }
         Network.setMcastGroup(_fd, _mcastAddr.Address, _mcastInterface);
     }
     else
     {
         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);
         }
         _addr = Network.doBind(_fd, _addr);
     }
     _bound = true;
     _endpoint = _endpoint.endpoint(this);
     return _endpoint;
 }
Пример #10
0
        //
        // Only for use by UdpEndpoint.
        //
        internal UdpTransceiver(UdpEndpointI endpoint, ProtocolInstance instance, string host, int port,
                                string mcastInterface, bool connect)
        {
            _endpoint = endpoint;
            _instance = instance;
            _state = connect ? StateNeedConnect : StateNotConnected;
            _mcastInterface = mcastInterface;
            _incoming = true;
            _port = port;

            try
            {
                _addr = Network.getAddressForServer(host, port, instance.protocolSupport(), instance.preferIPv6());

                _readEventArgs = new SocketAsyncEventArgs();
                _readEventArgs.RemoteEndPoint = _addr;
                _readEventArgs.Completed += new EventHandler<SocketAsyncEventArgs>(ioCompleted);

                _writeEventArgs = new SocketAsyncEventArgs();
                _writeEventArgs.RemoteEndPoint = _addr;
                _writeEventArgs.Completed += new EventHandler<SocketAsyncEventArgs>(ioCompleted);

                _fd = Network.createServerSocket(true, _addr.AddressFamily, instance.protocolSupport());
                setBufSize(-1, -1);
                Network.setBlock(_fd, false);
            }
            catch(Ice.LocalException)
            {
                if(_readEventArgs != null)
                {
                    _readEventArgs.Dispose();
                }
                if(_writeEventArgs != null)
                {
                    _writeEventArgs.Dispose();
                }
                _fd = null;
                throw;
            }
        }
Пример #11
0
        //
        // Compare endpoints for sorting purposes
        //
        public override int CompareTo(EndpointI obj)
        {
            if (!(obj is UdpEndpointI))
            {
                return(type() < obj.type() ? -1 : 1);
            }

            UdpEndpointI p = (UdpEndpointI)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 (!_connect && p._connect)
            {
                return(-1);
            }
            else if (!p._connect && _connect)
            {
                return(1);
            }

            if (!connectionId_.Equals(p.connectionId_))
            {
                return(string.Compare(connectionId_, p.connectionId_, StringComparison.Ordinal));
            }

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

            int rc = string.Compare(_mcastInterface, p._mcastInterface, StringComparison.Ordinal);

            if (rc != 0)
            {
                return(rc);
            }

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

            return(string.Compare(_host, p._host, StringComparison.Ordinal));
        }
Пример #12
0
 //
 // Return a server side transceiver for this endpoint, or null if a
 // transceiver can only be created by an acceptor. In case a
 // transceiver 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 Transceiver transceiver(ref EndpointI endpoint)
 {
     UdpTransceiver p = new UdpTransceiver(instance_, _host, _port, _mcastInterface, _connect);
     endpoint = new UdpEndpointI(instance_, _host, p.effectivePort(), _mcastInterface, _mcastTtl, 
                                 _connect, connectionId_, _compress);
     return p;
 }