Пример #1
0
        public static UDPCarrier Create(string bindIp, int bindPort)
        {
            var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            //3. bind if necessary
            if (bindIp != "")
            {
                socket.Bind(new IPEndPoint(IPAddress.Parse(bindIp), bindPort));
            }

            //4. Create the carrier
            var pResult = new UDPCarrier(socket);

            return(pResult);
        }
Пример #2
0
        public static UDPCarrier Create(string bindIp, ushort bindPort, BaseProtocol pProtocol)
        {
            if (pProtocol == null)
            {
                Logger.FATAL("Protocol can't be null");
                return(null);
            }

            UDPCarrier pResult = Create(bindIp, bindPort);

            if (pResult == null)
            {
                Logger.FATAL("Unable to create UDP carrier");
                return(null);
            }

            pResult.Protocol = pProtocol.FarEndpoint;
            pProtocol.FarEndpoint.IOHandler = pResult;

            return(pResult);
        }
Пример #3
0
 public static UDPCarrier Create(string bindIp, int bindPort)
 {
     var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
     //3. bind if necessary
     if (bindIp != "")
     {
         socket.Bind(new IPEndPoint(IPAddress.Parse(bindIp), bindPort));
     }
     
     //4. Create the carrier
     var pResult = new UDPCarrier(socket);
     return pResult;
 }