Esempio n. 1
0
        public void BindLocalEndPoint(IPv4 srcIP, ushort srcPort)
        {
            DebugPrint("BindLocalEndPoint ({0:x8}/{1} ->)\n",
                       srcIP, srcPort);
            IPv4 srcAddr = srcIP;

            if (srcAddr != IPv4.Any &&
                udp.IsLocalAddress(srcAddr) == false)
            {
                throw new Exception("BindLocalEndPoint: InvalidEndPoint");
            }
            else
            {
                udp.Bind(srcAddr, srcPort);
                state = State.LocallyBound;
            }
        }
Esempio n. 2
0
        public void Bind(IEndPoint endPoint)
        {
            receiveEndPoint = (NanoEndPoint)endPoint;

            InitSocket();
            int result = UDP.Bind(socket, ref receiveEndPoint.address);

            if (result != 0)
            {
                throw new NanoSocketException("Socket Bind failed: address or port might already be in use");
            }
        }