コード例 #1
0
        public override void Bind(IPEndPoint localEndPoint)
        {
            if (m_boundAddress != null)
            {
                m_boundAddress.Dispose();
                m_boundAddress = null;
            }

            m_boundAddress = new SocketAddress(localEndPoint.Address, localEndPoint.Port);

            // Accoring MSDN bind returns 0 if succeeded
            // and SOCKET_ERROR otherwise
            if (0 != UnsafeMethods.bind(Handle, m_boundAddress.Buffer, m_boundAddress.Size))
            {
                throw new SocketException();
            }
        }
コード例 #2
0
ファイル: Socket.cs プロジェクト: songfj/AsyncIO
        public override void Bind(IPEndPoint localEndPoint)
        {
            if (m_boundAddress != null)
            {
                m_boundAddress.Dispose();
                m_boundAddress = null;
            }

            m_boundAddress = new SocketAddress(localEndPoint.Address, localEndPoint.Port);

            SocketError bindResult = (SocketError)UnsafeMethods.bind(Handle, m_boundAddress.Buffer, m_boundAddress.Size);

            if (bindResult != SocketError.Success)
            {
                throw new SocketException((int)bindResult);
            }
        }