Exemple #1
0
        //  Set address to listen on. return the used port
        public virtual void SetAddress(String addr)
        {
            m_address.Resolve(addr, m_options.IPv4Only);

            m_endpoint = m_address.ToString();
            try
            {
                m_handle =
                    new Socket(m_address.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

                //handle.Blocking = false;

                m_handle.ExclusiveAddressUse = false;
                m_handle.Bind(m_address.Address);
                m_handle.Listen(m_options.Backlog);
            }
            catch (SocketException ex)
            {
                Close();
                throw NetMQException.Create(ex);
            }

            m_socket.EventListening(m_endpoint, m_handle);

            m_port = ((IPEndPoint)m_handle.LocalEndPoint).Port;
        }
Exemple #2
0
        //  Set address to listen on. return the used port
        public virtual void SetAddress(String addr)
        {
            m_address.Resolve(addr, m_options.IPv4Only);

            m_endpoint = m_address.ToString();
            try
            {
                m_handle =
                    new Socket(m_address.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

                if (!m_options.IPv4Only && m_address.Address.AddressFamily == AddressFamily.InterNetworkV6)
                {
                    try
                    {
                        // This is not supported on old windows operation system and might throw exception
                        m_handle.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, 0);
                    }
                    catch
                    {
                    }
                }

                //handle.Blocking = false;

                m_handle.ExclusiveAddressUse = false;
                m_handle.Bind(m_address.Address);
                m_handle.Listen(m_options.Backlog);
            }
            catch (SocketException ex)
            {
                Close();
                throw NetMQException.Create(ex);
            }

            m_socket.EventListening(m_endpoint, m_handle);

            m_port = ((IPEndPoint)m_handle.LocalEndPoint).Port;
        }
Exemple #3
0
        public void Init(string network)
        {
            m_address = new PgmAddress(network);

            m_pgmSocket = new PgmSocket(m_options, PgmSocketType.Listener, m_address);
            m_pgmSocket.Init();

            m_handle = m_pgmSocket.FD;

            try
            {
                m_handle.Bind(m_address.Address);
                m_pgmSocket.InitOptions();
                m_handle.Listen(m_options.Backlog);
            }
            catch (SocketException ex)
            {
                Close();

                throw NetMQException.Create(ex);
            }

            m_socket.EventListening(m_address.ToString(), m_handle);
        }