示例#1
0
 public EndpointI_connectorsI(ProtocolInstance instance, string host, string res, EndpointI_connectors cb)
 {
     _instance = instance;
     _host     = host;
     _resource = res;
     _callback = cb;
 }
示例#2
0
 public TcpEndpointI(ProtocolInstance instance, string ho, int po, EndPoint sourceAddr, int ti, string conId,
                     bool co) :
     base(instance, ho, po, sourceAddr, conId)
 {
     _timeout  = ti;
     _compress = co;
 }
示例#3
0
文件: WSEndpoint.cs 项目: yzun/ice
        internal WSEndpoint(ProtocolInstance instance, Endpoint del, Ice.InputStream s)
        {
            _instance = instance;
            _delegate = del;

            _resource = s.ReadString();
        }
示例#4
0
 public StreamSocket(ProtocolInstance instance, Socket fd)
 {
     _fd = fd;
     _state = StateConnected;
     _desc = IceInternal.Network.fdToString(_fd);
     init(instance);
 }
示例#5
0
 public TcpEndpointI(ProtocolInstance instance, string ho, int po, EndPoint sourceAddr, int ti, string conId,
     bool co)
     : base(instance, ho, po, sourceAddr, conId)
 {
     _timeout = ti;
     _compress = co;
 }
示例#6
0
        internal WSEndpoint(ProtocolInstance instance, EndpointI del, BasicStream s)
        {
            _instance = instance;
            _delegate = (IPEndpointI)del;

            _resource = s.readString();
        }
示例#7
0
文件: StreamSocket.cs 项目: yzun/ice
        public StreamSocket(ProtocolInstance instance, Socket fd)
        {
            _instance = instance;
            _fd       = fd;
            _state    = StateConnected;

            try
            {
                _desc = Network.FdToString(_fd);
            }
            catch (Exception)
            {
                Network.CloseSocketNoThrow(_fd);
                throw;
            }

            Network.SetBlock(_fd, false);
            Network.SetTcpBufSize(_fd, _instance);

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

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

            //
            // For timeouts to work properly, we need to receive/send
            // the data in several chunks. Otherwise, we would only be
            // notified when all the data is received/written. The
            // connection timeout could easily be triggered when
            // receiging/sending large messages.
            //
            _maxSendPacketSize = Math.Max(512, Network.GetSendBufferSize(_fd));
            _maxRecvPacketSize = Math.Max(512, Network.GetRecvBufferSize(_fd));
        }
示例#8
0
文件: StreamSocket.cs 项目: yzun/ice
        public StreamSocket(ProtocolInstance instance, INetworkProxy proxy, EndPoint addr, EndPoint sourceAddr)
        {
            _instance   = instance;
            _proxy      = proxy;
            _addr       = addr;
            _sourceAddr = sourceAddr;
            _fd         = Network.CreateSocket(false, (_proxy != null ? _proxy.GetAddress() : _addr).AddressFamily);
            _state      = StateNeedConnect;

            Network.SetBlock(_fd, false);
            Network.SetTcpBufSize(_fd, _instance);

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

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

            //
            // For timeouts to work properly, we need to receive/send
            // the data in several chunks. Otherwise, we would only be
            // notified when all the data is received/written. The
            // connection timeout could easily be triggered when
            // receiging/sending large messages.
            //
            _maxSendPacketSize = Math.Max(512, Network.GetSendBufferSize(_fd));
            _maxRecvPacketSize = Math.Max(512, Network.GetRecvBufferSize(_fd));
        }
示例#9
0
        internal WSEndpoint(ProtocolInstance instance, EndpointI del, BasicStream s)
        {
            _instance = instance;
            _delegate = (IPEndpointI)del;

            _resource = s.readString();
        }
示例#10
0
 public StreamSocket(ProtocolInstance instance, Socket fd)
 {
     _instance = instance;
     _fd       = fd;
     _state    = StateConnected;
     _desc     = IceInternal.Network.fdToString(_fd);
     init();
 }
示例#11
0
 public IPEndpoint(ProtocolInstance instance)
 {
     Instance         = instance;
     Host             = null;
     Port             = 0;
     SourceAddr       = null;
     ConnectionId_    = "";
     _hashInitialized = false;
 }
示例#12
0
 public IPEndpoint(ProtocolInstance instance, string host, int port, EndPoint?sourceAddr, string connectionId)
 {
     Instance         = instance;
     Host             = host;
     Port             = port;
     SourceAddr       = sourceAddr;
     ConnectionId_    = connectionId;
     _hashInitialized = false;
 }
示例#13
0
 public IPEndpoint(ProtocolInstance instance, Ice.InputStream s)
 {
     Instance         = instance;
     Host             = s.ReadString();
     Port             = s.ReadInt();
     SourceAddr       = null;
     ConnectionId_    = "";
     _hashInitialized = false;
 }
示例#14
0
 public IPEndpointI(ProtocolInstance instance, string host, int port, EndPoint sourceAddr, string connectionId)
 {
     instance_ = instance;
     host_ = host;
     port_ = port;
     sourceAddr_ = sourceAddr;
     connectionId_ = connectionId;
     _hashInitialized = false;
 }
示例#15
0
 public UdpEndpointI(ProtocolInstance instance, string ho, int po, EndPoint sourceAddr, string mcastInterface,
                     int mttl, bool conn, string conId, bool co) :
     base(instance, ho, po, sourceAddr, conId)
 {
     _mcastInterface = mcastInterface;
     _mcastTtl       = mttl;
     _connect        = conn;
     _compress       = co;
 }
示例#16
0
 public IPEndpointI(ProtocolInstance instance, BasicStream s)
 {
     instance_ = instance;
     host_ = s.readString();
     port_ = s.readInt();
     sourceAddr_ = null;
     connectionId_ = "";
     _hashInitialized = false;
 }
示例#17
0
 public IPEndpointI(ProtocolInstance instance, Ice.InputStream s)
 {
     instance_        = instance;
     host_            = s.readString();
     port_            = s.readInt();
     sourceAddr_      = null;
     connectionId_    = "";
     _hashInitialized = false;
 }
示例#18
0
 public IPEndpointI(ProtocolInstance instance)
 {
     instance_        = instance;
     host_            = null;
     port_            = 0;
     sourceAddr_      = null;
     connectionId_    = "";
     _hashInitialized = false;
 }
示例#19
0
 public IPEndpointI(ProtocolInstance instance)
 {
     instance_ = instance;
     host_ = null;
     port_ = 0;
     sourceAddr_ = null;
     connectionId_ = "";
     _hashInitialized = false;
 }
示例#20
0
 public UdpEndpointI(ProtocolInstance instance, string ho, int po, EndPoint sourceAddr, string mcastInterface,
                     int mttl, bool conn, string conId, bool co)
     : base(instance, ho, po, sourceAddr, conId)
 {
     _mcastInterface = mcastInterface;
     _mcastTtl = mttl;
     _connect = conn;
     _compress = co;
 }
示例#21
0
 public IPEndpointI(ProtocolInstance instance, string host, int port, EndPoint sourceAddr, string connectionId)
 {
     instance_        = instance;
     host_            = host;
     port_            = port;
     sourceAddr_      = sourceAddr;
     connectionId_    = connectionId;
     _hashInitialized = false;
 }
示例#22
0
        setTcpBufSize(Socket socket, ProtocolInstance instance)
        {
            //
            // By default, on Windows we use a 128KB buffer size.
            int dfltBufSize = 128 * 1024;
            int rcvSize     = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.RcvSize", dfltBufSize);
            int sndSize     = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.SndSize", dfltBufSize);

            setTcpBufSize(socket, rcvSize, sndSize, instance);
        }
示例#23
0
        public StreamSocket(ProtocolInstance instance, NetworkProxy proxy, EndPoint addr, EndPoint sourceAddr)
        {
            _proxy = proxy;
            _addr = addr;
            _sourceAddr = sourceAddr;
            _fd = Network.createSocket(false, (_proxy != null ? _proxy.getAddress() : _addr).AddressFamily);
            _state = StateNeedConnect;

            init(instance);
        }
示例#24
0
        public StreamSocket(ProtocolInstance instance, NetworkProxy proxy, EndPoint addr, EndPoint sourceAddr)
        {
            _instance   = instance;
            _proxy      = proxy;
            _addr       = addr;
            _sourceAddr = sourceAddr;
            _fd         = Network.createSocket(false, (_proxy != null ? _proxy.getAddress() : _addr).AddressFamily);
            _state      = StateNeedConnect;

            init();
        }
示例#25
0
        internal WSEndpoint(ProtocolInstance instance, EndpointI del, List <string> args)
        {
            _instance = instance;
            _delegate = (IPEndpointI)del;

            initWithOptions(args);

            if (_resource == null)
            {
                _resource = "/";
            }
        }
示例#26
0
        internal WSEndpoint(ProtocolInstance instance, EndpointI del, List<string> args)
        {
            _instance = instance;
            _delegate = (IPEndpointI)del;

            initWithOptions(args);

            if(_resource == null)
            {
                _resource = "/";
            }
        }
示例#27
0
        //
        // Only for use by UdpConnector.
        //
        internal UdpTransceiver(ProtocolInstance instance, EndPoint addr, EndPoint sourceAddr, string mcastInterface,
                                int mcastTtl)
        {
            _instance   = instance;
            _addr       = addr;
            _sourceAddr = sourceAddr;

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

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

            _mcastInterface = mcastInterface;
            _mcastTtl       = mcastTtl;
            _state          = StateNeedConnect;
            _incoming       = false;

            try
            {
                _fd = Network.createSocket(true, _addr.AddressFamily);
                setBufSize(-1, -1);
                Network.setBlock(_fd, false);
                if (Network.isMulticast((IPEndPoint)_addr))
                {
                    if (_mcastInterface.Length > 0)
                    {
                        Network.setMcastInterface(_fd, _mcastInterface, _addr.AddressFamily);
                    }
                    if (AssemblyUtil.osx_)
                    {
                        //
                        // On Windows, we delay the join for the mcast group after the connection
                        // establishment succeeds. This is necessary for older Windows versions
                        // where joining the group fails if the socket isn't bound. See ICE-5113.
                        //
                        Network.setMcastGroup(_fd, ((IPEndPoint)_addr).Address, _mcastInterface);
                        if (_mcastTtl != -1)
                        {
                            Network.setMcastTtl(_fd, _mcastTtl, _addr.AddressFamily);
                        }
                    }
                }
            }
            catch (Ice.LocalException)
            {
                _fd = null;
                throw;
            }
        }
示例#28
0
        //
        // Only for use by UdpConnector.
        //
        internal UdpTransceiver(ProtocolInstance instance, EndPoint addr, EndPoint sourceAddr, string mcastInterface,
                                int mcastTtl)
        {
            _instance = instance;
            _addr = addr;
            _sourceAddr = sourceAddr;

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

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

            _mcastInterface = mcastInterface;
            _mcastTtl = mcastTtl;
            _state = StateNeedConnect;
            _incoming = false;

            try
            {
                _fd = Network.createSocket(true, _addr.AddressFamily);
                setBufSize(-1, -1);
                Network.setBlock(_fd, false);
                if(Network.isMulticast((IPEndPoint)_addr))
                {
                    if(_mcastInterface.Length > 0)
                    {
                        Network.setMcastInterface(_fd, _mcastInterface, _addr.AddressFamily);
                    }
                    if(AssemblyUtil.osx_)
                    {
                        //
                        // On Windows, we delay the join for the mcast group after the connection
                        // establishment succeeds. This is necessary for older Windows versions
                        // where joining the group fails if the socket isn't bound. See ICE-5113.
                        //
                        Network.setMcastGroup(_fd, ((IPEndPoint)_addr).Address, _mcastInterface);
                        if(_mcastTtl != -1)
                        {
                            Network.setMcastTtl(_fd, _mcastTtl, _addr.AddressFamily);
                        }
                    }
                }
            }
            catch(Ice.LocalException)
            {
                _fd = null;
                throw;
            }
        }
示例#29
0
文件: WSEndpoint.cs 项目: yzun/ice
#pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
        internal WSEndpoint(ProtocolInstance instance, Endpoint del, List <string> args)
#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
        {
            _instance = instance;
            _delegate = del;

            InitWithOptions(args);

            if (_resource == null)
            {
                _resource = "/";
            }
        }
示例#30
0
 public UdpEndpointI(ProtocolInstance instance, BasicStream s) :
     base(instance, s)
 {
     if(s.getReadEncoding().Equals(Ice.Util.Encoding_1_0))
     {
         s.readByte();
         s.readByte();
         s.readByte();
         s.readByte();
     }
     // Not transmitted.
     //_connect = s.readBool();
     _connect = false;
     _compress = s.readBool();
 }
示例#31
0
 public UdpEndpointI(ProtocolInstance instance, Ice.InputStream s) :
     base(instance, s)
 {
     if (s.getEncoding().Equals(Ice.Util.Encoding_1_0))
     {
         s.readByte();
         s.readByte();
         s.readByte();
         s.readByte();
     }
     // Not transmitted.
     //_connect = s.readBool();
     _connect  = false;
     _compress = s.readBool();
 }
示例#32
0
文件: Network.cs 项目: skyccn/ice
        setTcpBufSize(Socket socket, int rcvSize, int sndSize, ProtocolInstance instance)
        {
            if (rcvSize > 0)
            {
                //
                // Try to set the buffer size. The kernel will silently adjust
                // the size to an acceptable value. Then read the size back to
                // get the size that was actually set.
                //
                setRecvBufferSize(socket, rcvSize);
                int size = getRecvBufferSize(socket);
                if (size < rcvSize)
                {
                    // Warn if the size that was set is less than the requested size and
                    // we have not already warned.
                    BufSizeWarnInfo winfo = instance.getBufSizeWarn(Ice.TCPEndpointType.value);
                    if (!winfo.rcvWarn || rcvSize != winfo.rcvSize)
                    {
                        instance.logger().warning("TCP receive buffer size: requested size of " + rcvSize +
                                                  " adjusted to " + size);
                        instance.setRcvBufSizeWarn(Ice.TCPEndpointType.value, rcvSize);
                    }
                }
            }

            if (sndSize > 0)
            {
                //
                // Try to set the buffer size. The kernel will silently adjust
                // the size to an acceptable value. Then read the size back to
                // get the size that was actually set.
                //
                setSendBufferSize(socket, sndSize);
                int size = getSendBufferSize(socket);
                if (size < sndSize) // Warn if the size that was set is less than the requested size.
                {
                    // Warn if the size that was set is less than the requested size and
                    // we have not already warned.
                    BufSizeWarnInfo winfo = instance.getBufSizeWarn(Ice.TCPEndpointType.value);
                    if (!winfo.sndWarn || sndSize != winfo.sndSize)
                    {
                        instance.logger().warning("TCP send buffer size: requested size of " + sndSize +
                                                  " adjusted to " + size);
                        instance.setSndBufSizeWarn(Ice.TCPEndpointType.value, sndSize);
                    }
                }
            }
        }
示例#33
0
 public StreamSocket(ProtocolInstance instance, Socket fd)
 {
     _instance = instance;
     _fd = fd;
     _state = StateConnected;
     try
     {
         _desc = IceInternal.Network.fdToString(_fd);
     }
     catch(Exception)
     {
         Network.closeSocketNoThrow(_fd);
         throw;
     }
     init();
 }
示例#34
0
 public StreamSocket(ProtocolInstance instance, Socket fd)
 {
     _instance = instance;
     _fd       = fd;
     _state    = StateConnected;
     try
     {
         _desc = Network.fdToString(_fd);
     }
     catch (Exception)
     {
         Network.closeSocketNoThrow(_fd);
         throw;
     }
     init();
 }
示例#35
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)
示例#36
0
文件: Network.cs 项目: yzun/ice
        SetTcpBufSize(Socket socket, ProtocolInstance instance)
        {
            //
            // By default, on Windows we use a 128KB buffer size. On Unix
            // platforms, we use the system defaults.
            //
            int dfltBufSize = 0;

            if (AssemblyUtil.IsWindows)
            {
                dfltBufSize = 128 * 1024;
            }
            int rcvSize = instance.Communicator.GetPropertyAsInt("Ice.TCP.RcvSize") ?? dfltBufSize;
            int sndSize = instance.Communicator.GetPropertyAsInt("Ice.TCP.SndSize") ?? dfltBufSize;

            SetTcpBufSize(socket, rcvSize, sndSize, instance);
        }
示例#37
0
文件: Network.cs 项目: skyccn/ice
        setTcpBufSize(Socket socket, ProtocolInstance instance)
        {
            //
            // By default, on Windows we use a 128KB buffer size. On Unix
            // platforms, we use the system defaults.
            //
            int dfltBufSize = 0;

            if (AssemblyUtil.isWindows)
            {
                dfltBufSize = 128 * 1024;
            }
            int rcvSize = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.RcvSize", dfltBufSize);
            int sndSize = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.SndSize", dfltBufSize);

            setTcpBufSize(socket, rcvSize, sndSize, instance);
        }
示例#38
0
        //
        // Only for use by TcpEndpoint
        //
        internal TcpConnector(ProtocolInstance instance, EndPoint addr, NetworkProxy proxy, EndPoint sourceAddr,
                              int timeout, string connectionId)
        {
            _instance     = instance;
            _addr         = addr;
            _proxy        = proxy;
            _sourceAddr   = sourceAddr;
            _timeout      = timeout;
            _connectionId = connectionId;

            _hashCode = 5381;
            HashUtil.hashAdd(ref _hashCode, _addr);
            if (_sourceAddr != null)
            {
                HashUtil.hashAdd(ref _hashCode, _sourceAddr);
            }
            HashUtil.hashAdd(ref _hashCode, _timeout);
            HashUtil.hashAdd(ref _hashCode, _connectionId);
        }
示例#39
0
        //
        // Only for use by TcpEndpoint
        //
        internal TcpConnector(ProtocolInstance instance, EndPoint addr, NetworkProxy proxy, EndPoint sourceAddr,
                              int timeout, string connectionId)
        {
            _instance = instance;
            _addr = addr;
            _proxy = proxy;
            _sourceAddr = sourceAddr;
            _timeout = timeout;
            _connectionId = connectionId;

            _hashCode = 5381;
            IceInternal.HashUtil.hashAdd(ref _hashCode, _addr);
            if(_sourceAddr != null)
            {
                IceInternal.HashUtil.hashAdd(ref _hashCode, _sourceAddr);
            }
            IceInternal.HashUtil.hashAdd(ref _hashCode, _timeout);
            IceInternal.HashUtil.hashAdd(ref _hashCode, _connectionId);
        }
示例#40
0
        //
        // Only for use by UdpConnector.
        //
        internal UdpTransceiver(ProtocolInstance instance, EndPoint addr, EndPoint sourceAddr, string mcastInterface,
                                int mcastTtl)
        {
            _instance   = instance;
            _addr       = addr;
            _sourceAddr = sourceAddr;

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

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

            _mcastInterface = mcastInterface;
            _state          = StateNeedConnect;
            _incoming       = false;

            try
            {
                _fd = Network.createSocket(true, _addr.AddressFamily);
                setBufSize(-1, -1);
                Network.setBlock(_fd, false);
                if (Network.isMulticast((IPEndPoint)_addr))
                {
                    if (_mcastInterface.Length > 0)
                    {
                        Network.setMcastInterface(_fd, _mcastInterface, _addr.AddressFamily);
                    }
                    if (mcastTtl != -1)
                    {
                        Network.setMcastTtl(_fd, mcastTtl, _addr.AddressFamily);
                    }
                }
            }
            catch (Ice.LocalException)
            {
                _fd = null;
                throw;
            }
        }
示例#41
0
文件: TcpAcceptor.cs 项目: yzun/ice
        internal TcpAcceptor(TcpEndpoint endpoint, ProtocolInstance instance, string host, int port)
        {
            _endpoint = endpoint;
            _instance = instance;
            _backlog  = instance.Communicator.GetPropertyAsInt("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;
            }
        }
示例#42
0
        //
        // Only for use by UdpEndpointI
        //
        internal UdpConnector(ProtocolInstance instance, EndPoint addr, EndPoint sourceAddr, string mcastInterface,
                              int mcastTtl, string connectionId)
        {
            _instance       = instance;
            _addr           = addr;
            _sourceAddr     = sourceAddr;
            _mcastInterface = mcastInterface;
            _mcastTtl       = mcastTtl;
            _connectionId   = connectionId;

            _hashCode = 5381;
            IceInternal.HashUtil.hashAdd(ref _hashCode, _addr);
            if (sourceAddr != null)
            {
                IceInternal.HashUtil.hashAdd(ref _hashCode, _sourceAddr);
            }
            IceInternal.HashUtil.hashAdd(ref _hashCode, _mcastInterface);
            IceInternal.HashUtil.hashAdd(ref _hashCode, _mcastTtl);
            IceInternal.HashUtil.hashAdd(ref _hashCode, _connectionId);
        }
示例#43
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;
            }
        }
示例#44
0
        //
        // Only for use by UdpEndpointI
        //
        internal UdpConnector(ProtocolInstance instance, EndPoint addr, EndPoint sourceAddr, string mcastInterface,
                              int mcastTtl, string connectionId)
        {
            _instance = instance;
            _addr = addr;
            _sourceAddr = sourceAddr;
            _mcastInterface = mcastInterface;
            _mcastTtl = mcastTtl;
            _connectionId = connectionId;

            _hashCode = 5381;
            IceInternal.HashUtil.hashAdd(ref _hashCode, _addr);
            if(sourceAddr != null)
            {
                IceInternal.HashUtil.hashAdd(ref _hashCode, _sourceAddr);
            }
            IceInternal.HashUtil.hashAdd(ref _hashCode, _mcastInterface);
            IceInternal.HashUtil.hashAdd(ref _hashCode, _mcastTtl);
            IceInternal.HashUtil.hashAdd(ref _hashCode, _connectionId);
        }
示例#45
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;
            }
        }
示例#46
0
 internal TcpEndpointFactory(ProtocolInstance instance)
 {
     _instance = instance;
 }
示例#47
0
文件: WSEndpoint.cs 项目: externl/ice
 public EndpointFactory clone(ProtocolInstance instance)
 {
     Debug.Assert(false); // We don't support cloning this transport.
     return null;
 }
示例#48
0
        public void finishSetup(ref string[] args, Ice.Communicator communicator)
        {
            //
            // Load plug-ins.
            //
            Debug.Assert(_serverThreadPool == null);
            Ice.PluginManagerI pluginManagerImpl = (Ice.PluginManagerI)_pluginManager;
            pluginManagerImpl.loadPlugins(ref args);

            //
            // Add WS and WSS endpoint factories if TCP/SSL factories are installed.
            //
            EndpointFactory tcpFactory = _endpointFactoryManager.get(Ice.TCPEndpointType.value);
            if(tcpFactory != null)
            {
                ProtocolInstance instance = new ProtocolInstance(this, Ice.WSEndpointType.value, "ws", false);
                _endpointFactoryManager.add(new WSEndpointFactory(instance, tcpFactory.clone(instance, null)));
            }
            EndpointFactory sslFactory = _endpointFactoryManager.get(Ice.SSLEndpointType.value);
            if(sslFactory != null)
            {
                ProtocolInstance instance = new ProtocolInstance(this, Ice.WSSEndpointType.value, "wss", true);
                _endpointFactoryManager.add(new WSEndpointFactory(instance, sslFactory.clone(instance, null)));
            }

            //
            // Create Admin facets, if enabled.
            //
            // Note that any logger-dependent admin facet must be created after we load all plugins,
            // since one of these plugins can be a Logger plugin that sets a new logger during loading
            //

            if(_initData.properties.getProperty("Ice.Admin.Enabled").Length == 0)
            {
                _adminEnabled = _initData.properties.getProperty("Ice.Admin.Endpoints").Length > 0;
            }
            else
            {
                _adminEnabled = _initData.properties.getPropertyAsInt("Ice.Admin.Enabled") > 0;
            }

            string[] facetFilter = _initData.properties.getPropertyAsList("Ice.Admin.Facets");
            if(facetFilter.Length > 0)
            {
                foreach(string s in facetFilter)
                {
                    _adminFacetFilter.Add(s);
                }
            }

            if(_adminEnabled)
            {
                //
                // Process facet
                //
                string processFacetName = "Process";
                if(_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(processFacetName))
                {
                    _adminFacets.Add(processFacetName, new ProcessI(communicator));
                }

                //
                // Logger facet
                //
                string loggerFacetName = "Logger";
                if(_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(loggerFacetName))
                {
                    LoggerAdminLogger logger = new LoggerAdminLoggerI(_initData.properties, _initData.logger);
                    setLogger(logger);
                    _adminFacets.Add(loggerFacetName, logger.getFacet());
                }

                //
                // Properties facet
                //
                string propertiesFacetName = "Properties";
                PropertiesAdminI propsAdmin = null;
                if(_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(propertiesFacetName))
                {
                     propsAdmin= new PropertiesAdminI(this);
                    _adminFacets.Add(propertiesFacetName, propsAdmin);
                }

                //
                // Metrics facet
                //
                string metricsFacetName = "Metrics";
                if(_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(metricsFacetName))
                {
                    CommunicatorObserverI observer = new CommunicatorObserverI(_initData);
                    _initData.observer = observer;
                    _adminFacets.Add(metricsFacetName, observer.getFacet());

                    //
                    // Make sure the admin plugin receives property updates.
                    //
                    if(propsAdmin != null)
                    {
                        propsAdmin.addUpdateCallback(observer.getFacet());
                    }
                }
            }

            //
            // Set observer updater
            //
            if(_initData.observer != null)
            {
                _initData.observer.setObserverUpdater(new ObserverUpdaterI(this));
            }

            //
            // Create threads.
            //
            try
            {
                if(initializationData().properties.getProperty("Ice.ThreadPriority").Length > 0)
                {
                    ThreadPriority priority = IceInternal.Util.stringToThreadPriority(
                                                initializationData().properties.getProperty("Ice.ThreadPriority"));
                    _timer = new Timer(this, priority);
                }
                else
                {
                    _timer = new Timer(this);
                }
            }
            catch(System.Exception ex)
            {
                string s = "cannot create thread for timer:\n" + ex;
                _initData.logger.error(s);
                throw;
            }

            try
            {
                _endpointHostResolver = new EndpointHostResolver(this);
            }
            catch(System.Exception ex)
            {
                string s = "cannot create thread for endpoint host resolver:\n" + ex;
                _initData.logger.error(s);
                throw;
            }
            _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0);

            //
            // The default router/locator may have been set during the loading of plugins.
            // Therefore we make sure it is not already set before checking the property.
            //
            if(_referenceFactory.getDefaultRouter() == null)
            {
                Ice.RouterPrx r = Ice.RouterPrxHelper.uncheckedCast(
                    _proxyFactory.propertyToProxy("Ice.Default.Router"));
                if(r != null)
                {
                    _referenceFactory = _referenceFactory.setDefaultRouter(r);
                }
            }

            if(_referenceFactory.getDefaultLocator() == null)
            {
                Ice.LocatorPrx l = Ice.LocatorPrxHelper.uncheckedCast(
                    _proxyFactory.propertyToProxy("Ice.Default.Locator"));
                if(l != null)
                {
                    _referenceFactory = _referenceFactory.setDefaultLocator(l);
                }
            }

            //
            // Show process id if requested (but only once).
            //
            lock(this)
            {
                if(!_printProcessIdDone && _initData.properties.getPropertyAsInt("Ice.PrintProcessId") > 0)
                {
                    using(Process p = Process.GetCurrentProcess())
                    {
                        System.Console.WriteLine(p.Id);
                    }
                    _printProcessIdDone = true;
                }
            }

            //
            // Server thread pool initialization is lazy in serverThreadPool().
            //

            //
            // An application can set Ice.InitPlugins=0 if it wants to postpone
            // initialization until after it has interacted directly with the
            // plug-ins.
            //
            if(_initData.properties.getPropertyAsIntWithDefault("Ice.InitPlugins", 1) > 0)
            {
                pluginManagerImpl.initializePlugins();
            }

            //
            // This must be done last as this call creates the Ice.Admin object adapter
            // and eventually registers a process proxy with the Ice locator (allowing
            // remote clients to invoke on Ice.Admin facets as soon as it's registered).
            //
            if(_initData.properties.getPropertyAsIntWithDefault("Ice.Admin.DelayCreation", 0) <= 0)
            {
                getAdmin();
            }
        }
示例#49
0
文件: WSEndpoint.cs 项目: externl/ice
 public void destroy()
 {
     _delegate.destroy();
     _instance = null;
 }
示例#50
0
文件: WSEndpoint.cs 项目: externl/ice
 internal WSEndpoint(ProtocolInstance instance, EndpointI del, string res)
 {
     _instance = instance;
     _delegate = (IPEndpointI)del;
     _resource = res;
 }
示例#51
0
 //
 // Only for use by TcpConnector, TcpAcceptor
 //
 internal TcpTransceiver(ProtocolInstance instance, StreamSocket stream)
 {
     _instance = instance;
     _stream = stream;
 }
示例#52
0
 public TcpEndpointI(ProtocolInstance instance, Ice.InputStream s)
     : base(instance, s)
 {
     _timeout = s.readInt();
     _compress = s.readBool();
 }
示例#53
0
 internal WSAcceptor(WSEndpoint endpoint, ProtocolInstance instance, Acceptor del)
 {
     _endpoint = endpoint;
     _instance = instance;
     _delegate = del;
 }
示例#54
0
 public void destroy()
 {
     _instance = null;
 }
示例#55
0
 public EndpointFactory clone(ProtocolInstance instance)
 {
     return new TcpEndpointFactory(instance);
 }
示例#56
0
 private void init(ProtocolInstance instance, Transceiver del)
 {
     _instance = instance;
     _delegate = del;
     _state = StateInitializeDelegate;
     _parser = new HttpParser();
     _readState = ReadStateOpcode;
     _readBuffer = new Buffer(ByteBuffer.ByteOrder.BIG_ENDIAN); // Network byte order
     _readBufferSize = 1024;
     _readLastFrame = true;
     _readOpCode = 0;
     _readHeaderLength = 0;
     _readPayloadLength = 0;
     _writeState = WriteStateHeader;
     _writeBuffer = new Buffer(ByteBuffer.ByteOrder.BIG_ENDIAN); // Network byte order
     _writeBufferSize = 1024;
     _readPending = false;
     _finishRead = false;
     _writePending = false;
     _readMask = new byte[4];
     _writeMask = new byte[4];
     _key = "";
     _pingPayload = new byte[0];
     _rand = new Random();
 }
示例#57
0
        internal WSTransceiver(ProtocolInstance instance, Transceiver del)
        {
            init(instance, del);
            _host = "";
            _port = -1;
            _resource = "";
            _incoming = true;

            //
            // Write and read buffer size must be large enough to hold the frame header!
            //
            Debug.Assert(_writeBufferSize > 256);
            Debug.Assert(_readBufferSize > 256);
        }
示例#58
0
        WSTransceiver(ProtocolInstance instance, Transceiver del, string host, int port, string resource)
        {
            init(instance, del);
            _host = host;
            _port = port;
            _resource = resource;
            _incoming = false;

            //
            // Use a 16KB write buffer size. We use 16KB for the write
            // buffer size because all the data needs to be copied to the
            // write buffer for the purpose of masking. A 16KB buffer
            // appears to be a good compromise to reduce the number of
            // socket write calls and not consume too much memory.
            //
            _writeBufferSize = 16 * 1024;

            //
            // Write and read buffer size must be large enough to hold the frame header!
            //
            Debug.Assert(_writeBufferSize > 256);
            Debug.Assert(_readBufferSize > 256);
        }
示例#59
0
 public TcpEndpointI(ProtocolInstance instance)
     : base(instance)
 {
     _timeout = instance.defaultTimeout();
     _compress = false;
 }
示例#60
0
        //
        // Only for use by Ice.CommunicatorI
        //
        public Instance(Ice.Communicator communicator, Ice.InitializationData initData)
        {
            _state = StateActive;
            _initData = initData;

            try
            {
                if(_initData.properties == null)
                {
                    _initData.properties = Ice.Util.createProperties();
                }
#if !SILVERLIGHT && !UNITY
                lock(_staticLock)
                {
                    if(!_oneOfDone)
                    {
                        string stdOut = _initData.properties.getProperty("Ice.StdOut");
                        string stdErr = _initData.properties.getProperty("Ice.StdErr");

                        System.IO.StreamWriter outStream = null;

                        if(stdOut.Length > 0)
                        {
                            try
                            {
                                outStream = System.IO.File.AppendText(stdOut);
                            }
                            catch(System.IO.IOException ex)
                            {
                                Ice.FileException fe = new Ice.FileException(ex);
                                fe.path = stdOut;
                                throw fe;
                            }
                            outStream.AutoFlush = true;
                            System.Console.Out.Close();
                            System.Console.SetOut(outStream);
                        }
                        if(stdErr.Length > 0)
                        {
                            if(stdErr.Equals(stdOut))
                            {
                                System.Console.SetError(outStream);
                            }
                            else
                            {
                                System.IO.StreamWriter errStream = null;
                                try
                                {
                                    errStream = System.IO.File.AppendText(stdErr);
                                }
                                catch(System.IO.IOException ex)
                                {
                                    Ice.FileException fe = new Ice.FileException(ex);
                                    fe.path = stdErr;
                                    throw fe;
                                }
                                errStream.AutoFlush = true;
                                System.Console.Error.Close();
                                System.Console.SetError(errStream);
                            }
                        }

                        _oneOfDone = true;
                    }
                }
#endif

                if(_initData.logger == null)
                {
#if !SILVERLIGHT && !UNITY
                    string logfile = _initData.properties.getProperty("Ice.LogFile");
                    if(_initData.properties.getPropertyAsInt("Ice.UseSyslog") > 0 &&
                       AssemblyUtil.platform_ != AssemblyUtil.Platform.Windows)
                    {
                        if(logfile.Length != 0)
                        {
                            throw new Ice.InitializationException("Ice.LogFile and Ice.UseSyslog cannot both be set.");
                        }
                        _initData.logger = new Ice.SysLoggerI(_initData.properties.getProperty("Ice.ProgramName"),
                            _initData.properties.getPropertyWithDefault("Ice.SyslogFacility", "LOG_USER"));
                    }
                    else if(logfile.Length != 0)
                    {

                        _initData.logger =
                            new Ice.FileLoggerI(_initData.properties.getProperty("Ice.ProgramName"), logfile);
                    }
                    else if(Ice.Util.getProcessLogger() is Ice.LoggerI)
                    {
                        //
                        // Ice.ConsoleListener is enabled by default.
                        //
#  if COMPACT
                        _initData.logger =
                            new Ice.ConsoleLoggerI(_initData.properties.getProperty("Ice.ProgramName"));
#  else
                        bool console =
                            _initData.properties.getPropertyAsIntWithDefault("Ice.ConsoleListener", 1) > 0;
                        _initData.logger =
                            new Ice.TraceLoggerI(_initData.properties.getProperty("Ice.ProgramName"), console);
#  endif
                    }
#else
                    if(Ice.Util.getProcessLogger() is Ice.LoggerI)
                    {
                        _initData.logger =
                            new Ice.ConsoleLoggerI(_initData.properties.getProperty("Ice.ProgramName"));
                    }
#endif
                    else
                    {
                        _initData.logger = Ice.Util.getProcessLogger();
                    }
                }

                _traceLevels = new TraceLevels(_initData.properties);

                _defaultsAndOverrides = new DefaultsAndOverrides(_initData.properties, _initData.logger);

                _clientACM = new ACMConfig(_initData.properties,
                                           _initData.logger,
                                           "Ice.ACM.Client",
                                           new ACMConfig(_initData.properties, _initData.logger, "Ice.ACM",
                                                         new ACMConfig(false)));

                _serverACM = new ACMConfig(_initData.properties,
                                           _initData.logger,
                                           "Ice.ACM.Server",
                                           new ACMConfig(_initData.properties, _initData.logger, "Ice.ACM",
                                                         new ACMConfig(true)));

#if COMPACT || SILVERLIGHT
                char[] separators = { ' ', '\t', '\n', '\r' };
                _factoryAssemblies = _initData.properties.getProperty("Ice.FactoryAssemblies").Split(separators);
#endif
                {
                    const int defaultMessageSizeMax = 1024;
                    int num =
                        _initData.properties.getPropertyAsIntWithDefault("Ice.MessageSizeMax", defaultMessageSizeMax);
                    if(num < 1 || num > 0x7fffffff / 1024)
                    {
                        _messageSizeMax = 0x7fffffff;
                    }
                    else
                    {
                        _messageSizeMax = num * 1024; // Property is in kilobytes, _messageSizeMax in bytes
                    }
                }

                if(_initData.properties.getProperty("Ice.BatchAutoFlushSize").Length == 0 && 
                   _initData.properties.getProperty("Ice.BatchAutoFlush").Length > 0)
                {
                    if(_initData.properties.getPropertyAsInt("Ice.BatchAutoFlush") > 0)
                    {
                        _batchAutoFlushSize = _messageSizeMax;
                    }
                }
                else
                {
                    int num = _initData.properties.getPropertyAsIntWithDefault("Ice.BatchAutoFlushSize", 1024); // 1MB
                    if(num < 1)
                    {
                        _batchAutoFlushSize = num;
                    }
                    else if(num > 0x7fffffff / 1024)
                    {
                        _batchAutoFlushSize = 0x7fffffff;
                    }
                    else
                    {
                        _batchAutoFlushSize = num * 1024; // Property is in kilobytes, _batchAutoFlushSize in bytes
                    }
                }

                _cacheMessageBuffers = _initData.properties.getPropertyAsIntWithDefault("Ice.CacheMessageBuffers", 2);

                _implicitContext = Ice.ImplicitContextI.create(_initData.properties.getProperty("Ice.ImplicitContext"));
                _routerManager = new RouterManager();

                _locatorManager = new LocatorManager(_initData.properties);

                _referenceFactory = new ReferenceFactory(this, communicator);

                _proxyFactory = new ProxyFactory(this);

                _requestHandlerFactory = new RequestHandlerFactory(this);

                bool isIPv6Supported = Network.isIPv6Supported();
                bool ipv4 = _initData.properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0;
                bool ipv6 = _initData.properties.getPropertyAsIntWithDefault("Ice.IPv6", isIPv6Supported ? 1 : 0) > 0;
                if(!ipv4 && !ipv6)
                {
                    throw new Ice.InitializationException("Both IPV4 and IPv6 support cannot be disabled.");
                }
                else if(ipv4 && ipv6)
                {
                    _protocolSupport = Network.EnableBoth;
                }
                else if(ipv4)
                {
                    _protocolSupport = Network.EnableIPv4;
                }
                else
                {
                    _protocolSupport = Network.EnableIPv6;
                }
                _preferIPv6 = _initData.properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0;

                _networkProxy = createNetworkProxy(_initData.properties, _protocolSupport);

                _endpointFactoryManager = new EndpointFactoryManager(this);
                ProtocolInstance tcpProtocolInstance = new ProtocolInstance(this, Ice.TCPEndpointType.value, "tcp");
                EndpointFactory tcpEndpointFactory = new TcpEndpointFactory(tcpProtocolInstance);
                _endpointFactoryManager.add(tcpEndpointFactory);

                ProtocolInstance udpProtocolInstance =
                    new ProtocolInstance(this, Ice.UDPEndpointType.value, "udp");
                EndpointFactory udpEndpointFactory = new UdpEndpointFactory(udpProtocolInstance);
                _endpointFactoryManager.add(udpEndpointFactory);

                ProtocolInstance wsProtocolInstance = new ProtocolInstance(this, Ice.WSEndpointType.value, "ws");
                _endpointFactoryManager.add(new WSEndpointFactory(wsProtocolInstance,
                                                                  tcpEndpointFactory.clone(wsProtocolInstance)));

#if !SILVERLIGHT
                _pluginManager = new Ice.PluginManagerI(communicator);
#endif

                _outgoingConnectionFactory = new OutgoingConnectionFactory(communicator, this);

                _servantFactoryManager = new ObjectFactoryManager();

                _objectAdapterFactory = new ObjectAdapterFactory(this, communicator);

                _retryQueue = new RetryQueue(this);
            }