Example #1
0
        internal TcpAcceptor(TcpEndpoint endpoint, TransportInstance instance, string host, int port)
        {
            _endpoint = endpoint;
            _instance = instance;
            _backlog  = instance.Communicator.GetPropertyAsInt("Ice.TCP.Backlog") ?? 511;

            try
            {
                int ipVersion = _instance.IPVersion;
                _addr = (IPEndPoint)Network.GetAddressForServer(host, port, ipVersion, _instance.PreferIPv6);
                _fd   = Network.CreateServerSocket(false, _addr.AddressFamily, ipVersion);
                Network.SetBlock(_fd, false);
                Network.SetTcpBufSize(_fd, _instance);
            }
            catch (Exception)
            {
                _fd = null;
                throw;
            }
        }
Example #2
0
        //
        // Only for use by UdpEndpoint.
        //
        internal UdpTransceiver(UdpEndpoint endpoint, TransportInstance 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.IPVersion, 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.IPVersion);
                SetBufSize(-1, -1);
                Network.SetBlock(_fd, false);
            }
            catch (Ice.LocalException)
            {
                if (_readEventArgs != null)
                {
                    _readEventArgs.Dispose();
                }
                if (_writeEventArgs != null)
                {
                    _writeEventArgs.Dispose();
                }
                _fd = null;
                throw;
            }
        }