Exemple #1
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);
        }
Exemple #2
0
 public void Dispose()
 {
     _tsa.Clear();
     _listener.Dispose();
     _sendChannel.Dispose();
     _listener     = null;
     _sendChannel  = null;
     onReceiveData = null;
 }
Exemple #3
0
        /// <summary>
        /// 创建一个信息发送通道
        /// </summary>
        /// <param name="remoteEndPoint"></param>
        /// <returns></returns>
        public UdpSendChannel CreateSendChannel(EndPoint remoteEndPoint)
        {
            var channel = new UdpSendChannel(_listener.Socket, remoteEndPoint, _tsa);

            return(channel);
        }