Пример #1
0
        /// <summary>
        /// 启动Socket服务
        /// </summary>
        /// <param name="host">监听的地址</param>
        /// <param name="bindPort">坚挺的端口</param>
        /// <param name="bufferSize">每一个连接的缓冲区大小</param>
        public void Bind(int localPort, ushort bufferSize)
        {
            Log.CI(ConsoleColor.DarkGreen, "Bind Udp Lisening {0}:{1}", IPAddress.Any, localPort);

            _listener = new UdpListener();
            _listener.onReceiveData += OnReceiveData;
            _listener.Bind(localPort, bufferSize, _tsa);
        }
Пример #2
0
        /// <summary>
        /// 绑定Udp主机
        /// </summary>
        /// <param name="remoteHost">远程主机地址</param>
        /// <param name="remotePort">远程主机端口</param>
        /// <param name="localPort">本地监听端口</param>
        /// <param name="bufferSize">缓冲区大小</param>
        public void Bind(string remoteHost, int remotePort, int localPort, ushort bufferSize)
        {
            _listener = new UdpListener();
            _listener.onReceiveData += OnReceiveData;
            var socket = _listener.Bind(localPort, bufferSize, _tsa);

            _sendChannel = new UdpSendChannel(socket, remoteHost, remotePort, _tsa);
        }